04-13-2018 05:32 AM
In those types of ASCII protocols, messages are usually terminated by a given character (or couple of characters).
You remarked that the command string should be terminated with \n, which is a readable representation of the line feed character (1 byte), whose numeric value is 10 dec, 0xA hex.
Most probably, also the instrument answer messages are terminated this way, so the real answer would be something like "22.64,46.7\n". The protocol documentation should specify which is the termination character (TermChar) of the answer.
With VISA, you can configure (with the VISA Configure etc.) a termination character in such a way that, when this character is received, the read is immediately terminated, irrespective of the number of characters you input to the VISA Read (provided that the number of characters is always greater than the length of any answer message you may receive). This is obviously very convenient.
The Read would then end whenever one of the following events occurs first:
- the termination character is received
- the specified number of characters is received
- the timeout time elapses
Only in the last case you get an error out of the VISA Read.
I hope this clarifies the issue about the termination character.
04-13-2018 05:42 AM
Thank a lot for your time to explain me the termination character.
Indeed, the answer is like "20.86,47.4\r", so I must put in the VISA Serial r.
I have seen that the constant created is by default an U8. How can I convert a char into an u8 ?
Thank a lot 🙂
04-13-2018 05:46 AM - edited 04-13-2018 05:49 AM
Hi Lablasc,
04-13-2018 06:12 AM
Perfect!
Thank a lot!
It works now :).
Thank you GerdW for all these advices and thank you pincpanter for your great explanation ! 🙂
Have a good day !