11-13-2008 12:05 AM
Hi all - been hacking away at something that should be simple for hours now, so I'm gonna ask for help...
I have an RS-485 device connected to COM5 via a USB adaptor, running at 9600 baud, 0,8,1,none - basic serial parameters. I can talk to the device using it's native terminal software, and even using hyperterminal with the above settings. It seems a no-brainer and so I thought LabVIEW and VISA would connect without much effort.
So I use the following simple sequence in LabVIEW:
- VISA configure serial port, 9600,0,8,1,none (no errors)
- VISA set buffer size, 4096 with a mask of 48 (no errors)
- VISA flush buffers, both buffers (no errors)
- VISA write, command string is "PR C2\r\n" which should be echoed, and return a numeric value (normally 0)
- check bytes at port property; returns 12
- VISA read, returns the command string only, 7 bytes
why can't I read the full buffer ?
To be honest, I thought this would just work with a trivial serial program: configure-write-read. But that always generates an error. I've added the buffer size since doing a bit of research and that makes it error free at least, though it's not in any of the published examples.
I don't think it's a delay issue, since I add plenty of delay when I'm debuging, and I have tried putting delays before the read. The fact that the byte count in the buffer is 12 seems to indicate my response is there somewhere...
I've also tried a second read but it doesn't return anything.
regards,
Lamb
Solved! Go to Solution.
11-13-2008 12:21 AM
Just disable the termination char.
That is the reason you only get one line.
Or do a second read at the end.
11-13-2008 12:22 AM
Hi Lamb,
maybe you enabled the termination character. And in your example the "\r\n" are on position 6 and 7.
Mike
11-13-2008 06:01 PM
Yeah, you guys are correct, and it seems so obvious now! That termination char is effectively being "recycled" since the command is being echoed.
Disabling the termination char fixes it. I also have the option of disabling the echo from the device...
thanks for the help