03-15-2017 03:48 PM
Hi,
I have optics module which communicate on serial bus. I am using Visa serial bus to talk to it.
Bus Frame is like this
1. Start of header : 1 byte
2. Address : 1 byte
3. Command :1byte
4. Data length: 1 Byte
5. Data: 0-255 Bytes
6. Checksum: 2bytes
I have to send command in hex format , and visa serial bus takes string to write it to the port.
i am not able to communicate with the module.
If the following frame needs to be transmitted: 0xF4, 0x41, 0x20, 0x00 the checksum should be as follows:
03-15-2017 05:12 PM
On mobile, so I cannot see your code. But my blind advice is to build your message using an array of bytes. You will need to convert to U16 for the checksum, split the result into 2 U8, and the build array to add the 2 bytes. Then use Byte Array To String, which then goes to the VISA Write.
03-15-2017 06:40 PM
Try this, I modified your code with 2 checksum methods.
It's tricky; I blame the documentation, if they would only provide a few data word examples with checksum so we programmers can test our routines on 'known' messages.
Also, what the 'sum' constitutes can be a variable, some systems only checksum the payload of the message and not the entire address and header bytes.
It's more error than trial.
Regards
Jack Hamilton
03-23-2017 07:01 AM
Thanks for the reply. I was able to get it work with you code. Had to twig my hardware one IC had gone bad.