03-06-2017 08:29 AM
Needed to move the string build to the outside of the while loop to contain the string when the last character is not a termination character and the enqueued string length is > 0.
03-06-2017 10:48 AM - edited 03-06-2017 10:52 AM
Hi Minions,
Thanks for the vi, it helped me to understand a bit but i need to read from the 2 ports.
So i can use the same vi for my 2nd port also, then dequeue and write to the 3rd port.
Did you check the vi if it can able to write to other port and data consistency is maintained, i.e., no mixing or missing of the data, also continuously sending serial data from 1 port and writing the data to other port.
Thanks
Aniket
03-07-2017 08:21 AM
Here is a cleaned up version of what you should be trying. Both Read loops will run until the stop is set. Inside their main loop, they will build the string without termination characters. Each time a termination character is received, it will send the string if it is > 0 characters. Once the string is sent, it will clear that string and begin building another. The write will also continue until the stop is set or there is an error during the dequeue process. Before dequeue, it checks to see if there is anything in the queue, if not, it will wait
W wait (ms)
time in milliseconds before checking the queue again.
03-07-2017 11:20 PM
Thanks Minions, i will check and let you know the outcome
03-08-2017 04:06 AM
Hi Minion,
As far as i understood, if there is no termination characters in data which i send then loop will run continuously and without writing to the port.
So i executed the vi you shared, my observation - vi trying to find the termination characters in the string and it continues to build the string. But what i am sending is without termination characters so vi won't work.
I am also looking for vi which can write data to other port irrespective of termination characters.
Regards
Aniket
03-08-2017 06:50 AM
Try re-enabling the termination characters in the read ports. In your current configuration, you will get interleaved data if it simply forwards the data in to the output port. How do you expect a program to know when the characters read from a port can be sent onto the output port without some sort of timeout or termination?
03-10-2017 03:23 AM
So i tried enabling the termination, but same result.
Also, radio data doesn't have the termination characters, so how to proceed then.
I successfully forwarded the data without any miss but it seems there is an issue with particular scenario - whenever my serial port is open and data is continuously received + my vi is stopped = after i start the vi, loads of data is transferred at one shot to the other port giving a very ugly picture.
How to resolve the issue because there are data at port and since there is no way to transfer the data to other port other than vi, it will store somewhere in buffer and as soon as i start the vi, a big chunk of data getting transferred at one shot - not good.
Thanks
Aniket
03-15-2017 08:38 AM
You might try to use the
Visa Flush I/O Buffer
right after your port initialization and before entering your producer loops. This should drop and clear any data awaiting on the port prior to the start of your vi.
03-15-2017 06:50 PM
Try this, I changed the delay function in your code to the metronome, it's provides much more reliable loop timing than the 'Wait ms'. In fact, don't ever use the Wait ms, unless you really understand why.
If that does not work, there is another technique of reading the chars from the port without a wait, that works when there is no termination character. It's involves a shift register.
Regards
Jack Hamilton
03-16-2017 10:09 AM