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

24 bit support #406

Merged
merged 2 commits into from
Dec 4, 2023
Merged

Conversation

raffi-g
Copy link
Contributor

@raffi-g raffi-g commented Nov 28, 2023

The unsigned24 part was already added in #267. I took the idea from there, but made it a little simpler. Also I added the signed version and extended the unit tests.

@raffi-g
Copy link
Contributor Author

raffi-g commented Nov 28, 2023

result from the test run:

collected 77 items                                                                                                                                                                                                                                                           

test/test_eds.py::TestEDS::test_array_compact_subobj PASSED                                                                                                                                                                                                            [  1%]
test/test_eds.py::TestEDS::test_comments PASSED                                                                                                                                                                                                                        [  2%]
test/test_eds.py::TestEDS::test_compact_subobj_parameter_name_with_percent PASSED                                                                                                                                                                                      [  3%]
test/test_eds.py::TestEDS::test_dummy_variable PASSED                                                                                                                                                                                                                  [  5%]
test/test_eds.py::TestEDS::test_dummy_variable_undefined PASSED                                                                                                                                                                                                        [  6%]
test/test_eds.py::TestEDS::test_explicit_name_subobj PASSED                                                                                                                                                                                                            [  7%]
test/test_eds.py::TestEDS::test_export_eds PASSED                                                                                                                                                                                                                      [  9%]
test/test_eds.py::TestEDS::test_load_file_object PASSED                                                                                                                                                                                                                [ 10%]
test/test_eds.py::TestEDS::test_load_nonexisting_file PASSED                                                                                                                                                                                                           [ 11%]
test/test_eds.py::TestEDS::test_parameter_name_with_percent PASSED                                                                                                                                                                                                     [ 12%]
test/test_eds.py::TestEDS::test_reading_factor PASSED                                                                                                                                                                                                                  [ 14%]
test/test_eds.py::TestEDS::test_record PASSED                                                                                                                                                                                                                          [ 15%]
test/test_eds.py::TestEDS::test_record_with_limits PASSED                                                                                                                                                                                                              [ 16%]
test/test_eds.py::TestEDS::test_relative_variable PASSED                                                                                                                                                                                                               [ 18%]
test/test_eds.py::TestEDS::test_signed_int_from_hex PASSED                                                                                                                                                                                                             [ 19%]
test/test_eds.py::TestEDS::test_sub_index_w_capital_s PASSED                                                                                                                                                                                                           [ 20%]
test/test_eds.py::TestEDS::test_variable PASSED                                                                                                                                                                                                                        [ 22%]
test/test_emcy.py::TestEmcyConsumer::test_emcy_list PASSED                                                                                                                                                                                                             [ 23%]
test/test_emcy.py::TestEmcyConsumer::test_str PASSED                                                                                                                                                                                                                   [ 24%]
test/test_emcy.py::TestEmcyProducer::test_send PASSED                                                                                                                                                                                                                  [ 25%]
test/test_local.py::TestSDO::test_abort PASSED                                                                                                                                                                                                                         [ 27%]
test/test_local.py::TestSDO::test_block_download_not_supported PASSED                                                                                                                                                                                                  [ 28%]
test/test_local.py::TestSDO::test_block_upload_switch_to_expedite_upload PASSED                                                                                                                                                                                        [ 29%]
test/test_local.py::TestSDO::test_callbacks PASSED                                                                                                                                                                                                                     [ 31%]
test/test_local.py::TestSDO::test_expedited_download PASSED                                                                                                                                                                                                            [ 32%]
test/test_local.py::TestSDO::test_expedited_download_wrong_datatype PASSED                                                                                                                                                                                             [ 33%]
test/test_local.py::TestSDO::test_expedited_upload PASSED                                                                                                                                                                                                              [ 35%]
test/test_local.py::TestSDO::test_expedited_upload_default_value_real PASSED                                                                                                                                                                                           [ 36%]
test/test_local.py::TestSDO::test_expedited_upload_default_value_visible_string PASSED                                                                                                                                                                                 [ 37%]
test/test_local.py::TestSDO::test_nmt_state_initializing_to_preoper PASSED                                                                                                                                                                                             [ 38%]
test/test_local.py::TestSDO::test_receive_abort_request PASSED                                                                                                                                                                                                         [ 40%]
test/test_local.py::TestSDO::test_segmented_download PASSED                                                                                                                                                                                                            [ 41%]
test/test_local.py::TestSDO::test_segmented_upload PASSED                                                                                                                                                                                                              [ 42%]
test/test_local.py::TestSDO::test_slave_send_heartbeat PASSED                                                                                                                                                                                                          [ 44%]
test/test_local.py::TestSDO::test_start_remote_node PASSED                                                                                                                                                                                                             [ 45%]
test/test_local.py::TestSDO::test_two_nodes_on_the_bus PASSED                                                                                                                                                                                                          [ 46%]
test/test_local.py::TestNMT::test_heartbeat PASSED                                                                                                                                                                                                                     [ 48%]
test/test_local.py::TestNMT::test_start_two_remote_nodes PASSED                                                                                                                                                                                                        [ 49%]
test/test_local.py::TestNMT::test_stop_two_remote_nodes_using_broadcast PASSED                                                                                                                                                                                         [ 50%]
test/test_local.py::TestPDO::test_read PASSED                                                                                                                                                                                                                          [ 51%]
test/test_local.py::TestPDO::test_save PASSED                                                                                                                                                                                                                          [ 53%]
test/test_network.py::TestNetwork::test_add_node PASSED                                                                                                                                                                                                                [ 54%]
test/test_network.py::TestNetwork::test_notify PASSED                                                                                                                                                                                                                  [ 55%]
test/test_network.py::TestNetwork::test_send PASSED                                                                                                                                                                                                                    [ 57%]
test/test_network.py::TestNetwork::test_send_perodic PASSED                                                                                                                                                                                                            [ 58%]
test/test_network.py::TestScanner::test_passive_scanning PASSED                                                                                                                                                                                                        [ 59%]
test/test_od.py::TestDataConversions::test_boolean PASSED                                                                                                                                                                                                              [ 61%]
test/test_od.py::TestDataConversions::test_integer16 PASSED                                                                                                                                                                                                            [ 62%]
test/test_od.py::TestDataConversions::test_integer24 PASSED                                                                                                                                                                                                            [ 63%]
test/test_od.py::TestDataConversions::test_integer32 PASSED                                                                                                                                                                                                            [ 64%]
test/test_od.py::TestDataConversions::test_integer8 PASSED                                                                                                                                                                                                             [ 66%]
test/test_od.py::TestDataConversions::test_unsigned16 PASSED                                                                                                                                                                                                           [ 67%]
test/test_od.py::TestDataConversions::test_unsigned24 PASSED                                                                                                                                                                                                           [ 68%]
test/test_od.py::TestDataConversions::test_unsigned32 PASSED                                                                                                                                                                                                           [ 70%]
test/test_od.py::TestDataConversions::test_unsigned8 PASSED                                                                                                                                                                                                            [ 71%]
test/test_od.py::TestDataConversions::test_visible_string PASSED                                                                                                                                                                                                       [ 72%]
test/test_od.py::TestAlternativeRepresentations::test_bits PASSED                                                                                                                                                                                                      [ 74%]
test/test_od.py::TestAlternativeRepresentations::test_desc PASSED                                                                                                                                                                                                      [ 75%]
test/test_od.py::TestAlternativeRepresentations::test_phys PASSED                                                                                                                                                                                                      [ 76%]
test/test_od.py::TestObjectDictionary::test_add_array PASSED                                                                                                                                                                                                           [ 77%]
test/test_od.py::TestObjectDictionary::test_add_record PASSED                                                                                                                                                                                                          [ 79%]
test/test_od.py::TestObjectDictionary::test_add_variable PASSED                                                                                                                                                                                                        [ 80%]
test/test_od.py::TestArray::test_subindexes PASSED                                                                                                                                                                                                                     [ 81%]
test/test_pdo.py::TestPDO::test_bit_mapping PASSED                                                                                                                                                                                                                     [ 83%]
test/test_sdo.py::TestSDO::test_abort PASSED                                                                                                                                                                                                                           [ 84%]
test/test_sdo.py::TestSDO::test_add_sdo_channel PASSED                                                                                                                                                                                                                 [ 85%]
test/test_sdo.py::TestSDO::test_block_download PASSED                                                                                                                                                                                                                  [ 87%]
test/test_sdo.py::TestSDO::test_block_upload PASSED                                                                                                                                                                                                                    [ 88%]
test/test_sdo.py::TestSDO::test_expedited_download PASSED                                                                                                                                                                                                              [ 89%]
test/test_sdo.py::TestSDO::test_expedited_upload PASSED                                                                                                                                                                                                                [ 90%]
test/test_sdo.py::TestSDO::test_segmented_download PASSED                                                                                                                                                                                                              [ 92%]
test/test_sdo.py::TestSDO::test_segmented_upload PASSED                                                                                                                                                                                                                [ 93%]
test/test_sdo.py::TestSDO::test_size_not_specified PASSED                                                                                                                                                                                                              [ 94%]
test/test_sdo.py::TestSDO::test_writable_file PASSED                                                                                                                                                                                                                   [ 96%]
test/test_sync.py::TestSync::test_sync_producer PASSED                                                                                                                                                                                                                 [ 97%]
test/test_sync.py::TestSync::test_sync_producer_counter PASSED                                                                                                                                                                                                         [ 98%]
test/test_time.py::TestTime::test_time_producer PASSED                                                                                                                                                                                                                 [100%]

============================================================================================================================ 77 passed in 13.57s =============================================================================================================================


class Unsigned24(struct.Struct):
def __init__(self, *args, **kwargs):
super().__init__("<L", *args, **kwargs)
Copy link
Owner

Choose a reason for hiding this comment

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

I'm suspecting the Struct class uses some clever logic with new instead of init. Maybe you can use composition instead of inheritance in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the hint. I'll have another look at it. I used Python 3.10. There the tests succeeded...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, apparently they changed something between py 3.10 and 3.12, where they enforce that the derived class has the same signature as the base class. I've changed to the composition approach now, as you suggested. The tests succeed now for 3.10 and 3.12. At least locally...

Unsigned24 was inspired by christiansandberg@659899d,
but kept a little simpler. I also added the signed version.

Signed-off-by: Greter Raffael <[email protected]>
Signed-off-by: Greter Raffael <[email protected]>
@christiansandberg christiansandberg merged commit 36900b1 into christiansandberg:master Dec 4, 2023
1 check passed
@raffi-g raffi-g deleted the 24-bit-support branch December 4, 2023 11:55
@acolomb acolomb added this to the v2.3.0 milestone Jun 11, 2024
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.

3 participants