07-05-2017 01:30 PM
The reader's address must be correct as i used FF (255) which sends the commands to all readers. Fixing the length didn't solve it. I used the codes you sent me. Maybe mistake is related to the CRC? If the command is incomplete, reader won't reply so probably its unable to identify the LSB And MSB
07-05-2017 02:53 PM - edited 07-05-2017 02:53 PM
This is an amazingly well-written document. You will have to calculate the length of the message. Command data block length 1 byte (not including itself). Value range is 4~96. The number of Len equals the length of Data [] plus 4. I take this to mean Adr + Cmd + CRC = 4 bytes + Data[]. In other words, concatenate your message with everything but Len. Take the size of that byte array, convert it to a u8 and tack it on to the front of the array. That's your message.
I think you have the importance of the various parts of your message failing all wrong. The length, which you assigned an arbitrary number to, is actually critical to the device understanding the message, while the CRC value just needs to be any u16.
Once you get a response back (that will probably tell you the command failed the CRC check), you can fool around with calculating the CRC value.
07-05-2017 03:15 PM - edited 07-05-2017 03:32 PM
This is how I would do it, based on the docs:
Oops, didn't optimize the read. See the post below.
07-05-2017 03:21 PM - edited 07-05-2017 03:46 PM
Oops, I didn't optimize the comm part. To read the response, first read one byte (VISA byte count = 1). The result is the length of the rest of the message (as u8). That's also your VISA byte count for your next (and final) VISA read. No more loop, no more "bytes at port". No more guessing at when the message is ending. You know when it ends. This is a very efficient protocol.
07-05-2017 03:58 PM - edited 07-05-2017 03:59 PM
Thinking about your problem further, you're probably not getting a response because bytes at port is likely still 0 when you look at it. That, plus the loop only executes once because of the true constant. You won't have that issue with the method I outlined above.
07-05-2017 05:33 PM
More than likely, you will also have to disable the termination character on both the VISA READ and WRITE functions.
07-06-2017 12:57 AM
Thank you all for your help, i am going to try the above as we speak. I' ll let you guys know what happens.
Thank you again.
07-06-2017 02:18 AM
Thanks alot. Its working fine. I would like to add that even though the length was correct the bytes at port property node was returning a 0, this is why i marked the second snippet as solution. Thank you sir.
07-06-2017 08:59 AM
You can mark more than one as a solution. I think this was a combination of several posts by a couple of different people. 🙂
You were awesome to dole out the kudos, though.
07-06-2017 01:59 PM
Yes, thanks to all of you. But the accept solution button isn't appearing anymore.