From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview Visa Termination Char Question

Hello again

 

This time i have a question regarding an annoyance, instead of a problem.

 

I use Labview VISA to communicate with an FTDI chip and do so by polling. VISA does a write with certain commands and then reads a response from FTDI chip (well, microcontroller). I manually set data packets to send, which include:

| Start char (0x02) | Data size H | Data size L | Command | Data0 ... DataX | XOR check | Term char (0x03) |

this is true for communication both ways. Unfortunately when VISA reads a response, some packets can be the same as term char set, which terminates read action prematurely. Right now i do some gymnastics around data sent in order to avoid it, but i'd much prefer a solution where VISA doesn't terminate read action on the first 0x03 it encounters, but rather when all data would be transferred.

 

I already tried communication without term char (also with polling) but it was unreliable and often incorrect.

 

So, any solutions to this or should i keep doing gymnastics?

 

Best regards

0 Kudos
Message 1 of 5
(1,993 Views)

To specify a bit, the gymnastics i do right now are avoiding writing the lowest bit, if data contains status flags and if the data is a number (say temperature) i convert it to unicode format and chop it up, then send it to Labview (so 125°C wouldn't be | 125 | ° | C | but rather | '1' | '2' | '5' | ° | C |). This one doesn't bother me that much, since i can just use convert string to number functions in VI.

0 Kudos
Message 2 of 5
(1,979 Views)

Could you share some example code to show how you are attempting to communicate here?  Assuming you are just using the VISA Configure Serial Port to initialize your session (also assuming you are using the Virtual Serial Port here), then you just need to make sure the termination character is turned off (set the Boolean to FALSE).  Other than that, it is just a matter of making sure you are synchronized by the frame.

 

So now my question goes into when the device sends you data.  Does it continuously send data (stream)?  Only when you request it (command-response)?  Or at seemingly random times (intermittent; this can include when a value changes, an error occurs, somebody presses a button, etc)?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 5
(1,957 Views)

"some packets can be the same as term char set"

And how do you expect any program to know when a term char is not really a term char? Maybe it is Term-Char only on Tuesdays, with positive time-zones?

It sounds like you need to implement a better protocol or change the term char. You already have the size in the message, so read the start PLUS size bytes, then the read that size.

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 4 of 5
(1,952 Views)

@Frozen wrote:

It sounds like you need to implement a better protocol or change the term char. You already have the size in the message, so read the start PLUS size bytes, then the read that size.


The protocol is actually VERY sound.  The solution is to not use the termination character and use the frame set up by the protocol.  I just need the last details I asked for in my previous post to finalize the actual solution to this issue.  You cannot just read the start and size bytes since you do not know if you are starting with the start of a frame.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 5
(1,934 Views)