Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented data sending to the device with send periodic #108

Merged
merged 4 commits into from
Sep 11, 2024

Conversation

novicatepic
Copy link
Collaborator

Define new message type sent from cloud to gateway for can messages.
Parse the message and send it to CAN python app.
Read the message and, based on type and action (if exists), send data to device with new thread, stop data sending from device and terminate the thread or return current values to cloud so cloud page is update with the latest information.

@novicatepic novicatepic self-assigned this Sep 9, 2024
@novicatepic novicatepic linked an issue Sep 9, 2024 that may be closed by this pull request
@@ -198,6 +198,31 @@ def update_protocols_on_startup(protocols):
session.close()


def publish_protocol_message_to_can_module(data):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the value processing done (multiplire, divisor, offset...)? On Cloud already?
If not, it should be covered on the gateway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved issue in latest commit.

msg = can.Message(
arbitration_id=int(hex_string, 16), data=byte_array, is_extended_id=False, is_remote_frame=False
value += protocol_data_from_db.offset_value
if protocol_data_from_db.divisor > 0:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should support negative values too.

byte_array = struct.pack('d', value)
extracted_value = extract_bits(byte_array, protocol_data_from_db.start_bit,
protocol_data_from_db.num_bits)
extracted_double_value = extracted_value / 10.0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write a comment why there is division by 10.

@sale3 sale3 merged commit 9c648b7 into master Sep 11, 2024
4 checks passed
@sale3 sale3 deleted the 105-gateway-enable-input-can-messages-sending-to-device branch September 11, 2024 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GATEWAY] Enable input CAN messages sending to device
2 participants