05-15-2015 05:00 AM
Hello guys,
I am trying to acquire data from serial port. I am using FTDI serial - usb converter.
I attached the vi example and captures.
It send CDD1 CDD3 CDD3 to device and the device send ADD1 ADD3, then I send CDD3 and device start to measure and send to serial port.
The first question is about the current way to comunicate with device is correct?.
The main question is about to stop the first loop when I turn off the device in middle of transmision (for example) or some times I dont know why, If I choose the incorrect port to check all is working ok, the port read the data i sent and send CDD3 CDD3. Then the loop 1 no stop!. I want programately the loop detect the " time out" and stop the loop.
One thing to keep in mind is the transmission is not without stops. When start the transmission the device send data, stop for maybe 2 or 3 seconds to change sensors and send again....
So, I would like if anyone can give me advises to stop the loop1 when it doesnt recieve data.
Thanks.
Solved! Go to Solution.
05-15-2015 06:15 AM
05-15-2015 07:17 AM
Dennis,
Yes, the images no show any error. The first picture shows that the device send to pc the correct bytes hex and show the bytes of string captured.
The second, show that If I put com3, that is not the usb-serial it sometimes can not open, this com3 is empty I dont have anything connected.
In other ocasions it open and read and send the bytes I wrote... so the program think its correct and is waitting for data, the loop1 no stop...
And also If i use the good com4, i want have any check to stop the loop1 if for error or person remove the cable or turn off the device...
I attached the block diagram and the sequence structure I am using... I dont know if it is better use flat sequence to have all the error wire conected... or better option.
Thanks for your time.
Fred.
05-15-2015 07:22 AM
What is the instrument you are trying to communicate with? Does it use a termination character? If not, then turn off the termination character on the Configure Serial Port. You should avoid using the Bytes At Port if at all possible. If you know how long of a message you are to recieve, just read that many characters.
05-15-2015 07:38 AM
05-15-2015 07:50 AM
Thanks,
You are right like Dennis, I needed to put off the termination character. It was a error since I am using lvr serial vis and build the example quickly, but at end its the same.
Yes, I know the number of bytes.
The device measure impedance, changing the freq of signal and sendding the data, that's way I wrote that the device one time i order to send it sends datas, 2048 bytes, change the freq, measure impedances and send... it no take more than 20 seconds the full test and between each freq it takes 2 to 4 seconds to again send the 2048 bytes. The total are 4 2048 bytes packages.
Fred
05-15-2015 07:54 AM
Ok, Dennis.
I will do so. I can create one error for any problem with serial number diferent. Its like eco, it read the same you write to port.
If I fix the number of bytes to read, I wouldnt need the loops. One thing is that I check each 2048 bytes to be sure the data is ok and stop the transmission if the values are no correct.
05-15-2015 08:41 AM
You are reading 4 bytes out of your serial port, then seeing if that is equal to a string that has at least 9 characters. They will never be equal!
05-15-2015 10:01 AM
05-15-2015 10:26 AM - edited 05-15-2015 10:26 AM
ravens,
I dont understand what you mean.
The system is easy, sorry If I didnt explain it well.
I modified a bit and it is :
My app say: CDD1
device reply: ADD1
My app say : CDD1 CDD3
device reply: ADD3
My app say: CDD3
device reply: Start transfering 4 blocks of 4096 bytes.
The stream stop 2 or 3sec between each block. (the device change the freq of signal, then measure and send the data).