05-23-2013 07:04 AM
Hi,
I am using serial communication to communicate with my device. It is some sort of water level data logger with other "options". But it really doesn't matter for my question.
The communication works with my attached file, but the it is very slow becouse. I wait too long for read VISA buffer (100ms). But if I wait less time, there comes to data loss. I tried to enable termination character but it didn't worke for me. I need to code that checks byte per byte and when it detects number 83 in hex it stops and return everything what has been read so far. The output data is every time a different size.
I make default values in Vi so you can see the input data and output (loggers answer).
Thanks for your help,
Božidar
05-23-2013 07:52 AM
My first question is, is this being used as a SubVI? I ask because I do not see your VISA Config Serial Port. Are you passing this over to your VISA Resource Control?
05-23-2013 07:53 AM
If you want to read everything up to the first 0x83 sign, use 0x83 as your termination char with a large number at the input byte count and you are done.
On a side node what baud rate are you using? The answer string that you posted in VI has a length of 93 bytes. At a typical rate of 9600 baud the transmission of this 93 bytes already needs about 100 ms.
Best regards
Jens
05-23-2013 07:55 AM
Also, you need to wire the error wire (yellow wire) into to and out of your Bytes to Port Property Node. Don't pass this.
05-23-2013 08:09 AM
Yes, this is SubVi. I use 38400 baud rate. I tried to use termination character with example Vi (advanced serial write and read communication) but no luck. Not a single byte came out.
05-23-2013 08:23 AM
Bozidar,
Can you post the part of your code that opens/configures the COM port?
05-23-2013 08:32 AM
Sure
05-23-2013 08:33 AM - edited 05-23-2013 08:36 AM
Seems that your communication always start with x82 and end with x83.
So configure the COM to terminate with CHAR x83
Try this (untested) with your COM setup before hitting RUN
05-23-2013 08:34 AM
@Bozidar wrote:
Yes, this is SubVi. I use 38400 baud rate. I tried to use termination character with example Vi (advanced serial write and read communication) but no luck. Not a single byte came out.
Then you've made something wrong in that example.
I just tried it by sending your example answer from one RS232 to another on my computer. Using 0x83 as termination char works fine. I either get a time-out or the complete string.
Back to timings in your example: Your request string is 23 bytes, your answer 93 bytes. At a baud rate of 38400 it takes about 30 ms to transmit these 116 bytes. Also take into account that your logger needs some time to put your request.
Best regards,
Jens
05-23-2013 08:39 AM
Why do you use 83dez as termination char in your "ConnectToDevice.vi"?
Display the radix on this U8 (right click -> Visible Items -> Radix) and change it to 0x83.
Best regards,
Jens