intrepidcs / python_ics

Library for interfacing with Intrepid devices in Python
MIT License
61 stars 31 forks source link

Please provide example for iso15765 #17

Closed pierreluctg closed 6 years ago

pierreluctg commented 6 years ago

Hi @drebbe-intrepid, can you please provide example and documentation on how to use ics.iso15765_receive_message() (and other iso15765 methods)

It is not clear to me how to use the iIndex argument is supposed to be use.

Thank you

drebbe-intrepid commented 6 years ago

I'm working on an example right now, iIndex is poorly named, it is the network id.

drebbe-intrepid commented 6 years ago

@pierreluctg https://github.com/intrepidcs/python_ics/blob/master/examples/iso15765_example.py

I had to fix some things to make this work, I'll be releasing a new version here soon once I cherry-pick back to 802 branch.

https://github.com/intrepidcs/python_ics/commit/9195d568f2f2dedbda80ecdf830cfb2d02a58cbc

drebbe-intrepid commented 6 years ago

screenshot of the example:

iso15765_example

drebbe-intrepid commented 6 years ago

@pierreluctg I Just uploaded 2.14 to pypi, example should be fully working now.

pierreluctg commented 6 years ago

Thank you @drebbe-intrepid

pierreluctg commented 6 years ago

@drebbe-intrepid I tried the example using python-ics 2.14 and only the First Frame is received in the RX side. The RX side is not sending the Flow Control and it prevents the TX side from sending the Consecutive Frames.

drebbe-intrepid commented 6 years ago

@pierreluctg I did see this behavior once but was unable to reproduce it. Can you let me know your setup again and console output?

pierreluctg commented 6 years ago

This is the output I get from running https://raw.githubusercontent.com/intrepidcs/python_ics/v802/examples/iso15765_example.py with python-ics 2.14, 2 x ValueCan3 and driver version 3.8.2.111

Opening Device ValueCAN3 87635 (Open Client handles: 0)...
Opened Device ValueCAN3 87635.
Opening Device ValueCAN3 87707 (Open Client handles: 0)...
Opened Device ValueCAN3 87707.
Setting up iso15765 message on ValueCAN3 87707...
Setup iso15765 message on ValueCAN3 87707.
Transmitting iso15765 message on ValueCAN3 87635...
Transmitted iso15765 message on ValueCAN3 87635.
Received 1 messages with 0 errors.
Message #1      ArbID: 0x7e0    Data: ['0x10', '0x40', '0x0', '0x1', '0x2', '0x3', '0x4', '0x5']

With enable_print_message = True

Opening Device ValueCAN3 87635 (Open Client handles: 0)...
Opened Device ValueCAN3 87635.
Opening Device ValueCAN3 87707 (Open Client handles: 0)...
Opened Device ValueCAN3 87707.
    <class 'ics.CmISO157652RxMessage'>
        blockSize:                     0x64
        cf_timeout:                    0x3e8
        extendedAddress:               0x0
        fc_id:                         0x7e8
        flags:                         0x40
        flowControlExtendedAddress:    0x0
        id:                            0x7e0
        id_mask:                       0xfff
        padding:                       0xaa
        reserved:                      (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
        stMin:                         0xa
        vs_netid:                      0x1

Setting up iso15765 message on ValueCAN3 87707...
Setup iso15765 message on ValueCAN3 87707.
Transmitting iso15765 message on ValueCAN3 87635...
Transmitted iso15765 message on ValueCAN3 87635.
Received 1 messages with 0 errors.
Message #1      <class 'ics.SpyMessage'>
        AckBytes:                      (0, 0, 0, 0, 0, 0, 0, 0)
        ArbIDOrHeader:                 0x7e0
        Data:                          (16, 64, 0, 1, 2, 3, 4, 5)
        DescriptionID:                 0x0
        ExtraDataPtr:                  None
        ExtraDataPtrEnabled:           0x0
        MessagePieceID:                0x0
        MiscData:                      0x0
        NetworkID:                     0x1
        NetworkID2:                    0x0
        NodeID:                        0x0
        NumberBytesData:               0x8
        NumberBytesHeader:             0x4
        Protocol:                      0x1
        StatusBitField:                0x4000000
        StatusBitField2:               0x0
        StatusBitField3:               0x0
        StatusBitField4:               0x0
        TimeHardware:                  0x5a243687
        TimeHardware2:                 0x3
        TimeStampHardwareID:           0x4
        TimeStampSystemID:             0x1
        TimeSystem:                    0x20fa80
        TimeSystem2:                   0x0
        noExtraDataPtrCleanup:         0x1
drebbe-intrepid commented 6 years ago

hmm, I suspect a possible issue with ValueCAN3 and not sending the response. I noticed my example I'm doing that with the FIRE2. I'll swap them around and see if I can reproduce it, but I won't be able to get to it until Monday as I'm out of the office until then.

pierreluctg commented 6 years ago

Thank you @drebbe-intrepid

drebbe-intrepid commented 6 years ago

@pierreluctg I've reproduced this on my side and submitted a bug to our internal tracker. Looks to be an issue with icsneoISO15765_ReceiveMessage() and ValueCAN3.

drebbe-intrepid commented 6 years ago

@pierreluctg I believe this should be fixed now. I had the shifting wrong for the flags and didn't have enableFlowControlTransmission set.

drebbe-intrepid commented 6 years ago

Updated console output with new code changes and two ValueCAN3s:

Opening Device ValueCAN3 140085 (Open Client handles: 0)...
Opened Device ValueCAN3 140085.
Opening Device ValueCAN3 140242 (Open Client handles: 0)...
Opened Device ValueCAN3 140242.
Setting up iso15765 message on ValueCAN3 140242...
Setup iso15765 message on ValueCAN3 140242.
Transmitting iso15765 message on ValueCAN3 140085...
Transmitted iso15765 message on ValueCAN3 140085.
Received 11 messages with 0 errors.
Message #1              ArbID: 0x7e0    Data: ['0x10', '0x40', '0x0', '0x1', '0x2', '0x3', '0x4', '0x5']
Message #2              ArbID: 0x7e8    Data: ['0x30', '0x64', '0xa', '0xaa', '0xaa', '0xaa', '0xaa', '0xaa']
Message #3              ArbID: 0x7e0    Data: ['0x21', '0x6', '0x7', '0x8', '0x9', '0xa', '0xb', '0xc']
Message #4              ArbID: 0x7e0    Data: ['0x22', '0xd', '0xe', '0xf', '0x10', '0x11', '0x12', '0x13']
Message #5              ArbID: 0x7e0    Data: ['0x23', '0x14', '0x15', '0x16', '0x17', '0x18', '0x19', '0x1a']
Message #6              ArbID: 0x7e0    Data: ['0x24', '0x1b', '0x1c', '0x1d', '0x1e', '0x1f', '0x20', '0x21']
Message #7              ArbID: 0x7e0    Data: ['0x25', '0x22', '0x23', '0x24', '0x25', '0x26', '0x27', '0x28']
Message #8              ArbID: 0x7e0    Data: ['0x26', '0x29', '0x2a', '0x2b', '0x2c', '0x2d', '0x2e', '0x2f']
Message #9              ArbID: 0x7e0    Data: ['0x27', '0x30', '0x31', '0x32', '0x33', '0x34', '0x35', '0x36']
Message #10             ArbID: 0x7e0    Data: ['0x28', '0x37', '0x38', '0x39', '0x3a', '0x3b', '0x3c', '0x3d']
Message #11             ArbID: 0x7e0    Data: ['0x29', '0x3e', '0x3f']
pierreluctg commented 6 years ago

Hi @drebbe-intrepid, confirming that it works now with this latest change.

Before pushing a new release can you look at #18 if that do not involve to much work.

Thank you

pierreluctg commented 6 years ago

Working with as expected latest release https://pypi.org/project/python-ics/2.15/