08-23-2007 02:29 AM
08-23-2007 02:54 AM - edited 08-23-2007 02:54 AM

Message Edited by Bill@NGC on 08-23-2007 12:55 AM
08-23-2007 10:11 PM
08-23-2007 10:25 PM
09-26-2007 10:56 PM
09-26-2007 11:24 PM
You did not provide the most important part to help solve the problem - the actual error code and message. You have a VISA Read after the VISA Write in the case statement. Assuming that you have all of this inside a while loop that's not seen, the VISA Read will always execute. Is there any data to be read if the true case is not selected? Assuming again you have an unseen while loop, your VISA Configure Serial Port should be outside the loop and only run once. That won't cause an error - it's just good programming.
09-27-2007 12:19 AM - edited 09-27-2007 12:19 AM
Hi Yush,
Your original post asked how to extract specific bytes from an 18-byte packet. One way might be to cast the packet directly to a cluster of bytes, and unbundle the bytes by name - it's pretty clean. But this assumes the packet is exactly the data you're expecting and if there's a leading character, checksum and/or CRC I'd add some code to check for it (before the cast.) Actually, to examine/dissect the packet for correctness I'd use the string-to-bytes method RF described and forget this casting!
(just add it to you bag of tricks...)
The posted .png shows some ambiguity re execution-order - theoretically, the writes for Reset, Scale, or Zero could occur AFTER the 'G'O
. I'd wire all these settings in a sequence!
Cheers!
Message Edited by tbd on 09-27-2007 12:30 AM
09-27-2007 12:30 AM
09-27-2007 01:05 AM
Hi Yush,
@Yush wrote:
Does it matter if there is no data to be read for the false case??
It could matter but the consequence of returning zeros (the default of the cast) depends on the context, the enclosing diagram - Dennis's "unseen while loop"! ![]()
The .png looked like example code and it wasn't obvious (to me) that the "Start" was necessary in order for data to be available ( maybe once started all that was needed is Read.) It also seemed the "Read" ought to be by itself, in a loop instead of doing the Config AND Read repeatedly. There ought to be a VISA Close somewhere too. ![]()
If the value of "Start" determines whether data will be available, then why call Read if Start=F? - no need for bytes-at-port then. If there's a Read alone in a while-loop, polling for data, then sure use bytes-at-port - or just let the Read time-out and throw an error - maybe you'll want to know if the device has stopped sending data?
Cheers!
09-27-2007 05:46 AM