LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial port read one character

Solved!
Go to solution

 

Hello

 

I am new to the forum, so I don't know if I am posting this question in the right place.

 

However, my problem is that I am trying to communicate via rs-232 serial port and the objective is to read and write the question (code) to the device.

 

The device sends regularly a "keeping alive" S character. When I read this character I write the question and receive the answer. Then an S appears again, and I wrtite the code, read the the answer and so on...

 

The problem is that when I try to do all at a time (read the S, send the code and read the answer) and do this 14 times before reach the 1st code again, labview is very slow. (3 to 5 seconds to do this 14 tasks and restart again the process). I think that the program becomes slow because this way I'm not making use of all the S that ignite the writing and reading process.

 

Thus, I wanted to read character by character (byte by byte) and then build an array with the answer. The problem is that buffer sends answers with several bytes and I cannot build an array in "real time", beacause if I read (VISA read) only one byte, then I would lost all the others.

 

I think concantenate strings and shift registers are part of the solution, but I am having too much problems before I reach that part.

 

So, please help me to read a single character and do not lost the other bytes sent by the buffer, in order to fasten the process, because I want a second by second actualization. The device has a 19200 baud rate.

 

Thanks in advance

0 Kudos
Message 1 of 5
(2,829 Views)
Solution
Accepted by topic author fadetoblack

I think if you wire the value 1, to the function read serial port, you will receive one byte and you will not loose the rest.

The rest are stored in the buffer. If you use the previous function again, you will get the next byte.

0 Kudos
Message 2 of 5
(2,798 Views)

Hello fadetobla...

 

could you please provide some explaining source code snippets.

I guess something is wrong with your code. I do not believe that reading the bytes one by one is necessary.

 

Regards,

Thomas

0 Kudos
Message 3 of 5
(2,760 Views)

Hello

 

Thanks for the help. I put VISA read with one character and it actually worked!!!

 

I've also put "VISA configure serial port" outside the loop where I was reading. I think that helped too, but I'm a rookie on Labview... and I'm not sure about it.

 

Once again, thaks for the help. It is working for now

 

 

Thanks

0 Kudos
Message 4 of 5
(2,745 Views)

fadetoblack wrote:

I've also put "VISA configure serial port" outside the loop where I was reading.


This is the correct place for it. You only have to initiallize once your port. (as long as you don't need to close it and reopen it)

0 Kudos
Message 5 of 5
(2,729 Views)