AnsweredAssumed Answered

vrf serial communication

Question asked by VRFuser on Apr 29, 2004
Latest reply on Oct 25, 2006 by fadi.ibrahim
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"><META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.45"><TITLE>Re: [vrf] serial communication</TITLE></HEAD><BODY><P><FONT SIZE=2>Another advise, before sending a query or command, flush the receive buffer (ie. read all of the data and discard it), so the response you will read after your transmission will be only related to the current communication.</FONT></P><P><FONT SIZE=2>-----Message d'origine-----</FONT><BR><FONT SIZE=2>De: Rufus Warren [<A HREF="mailto:rwarren@amti.net">mailto:rwarren@amti.net</A>]</FONT><BR><FONT SIZE=2>Date: 30 avril 2004 08:15</FONT></P><P><FONT SIZE=2>Try using a continuous read on a separate thread, make sure to catch any</FONT><BR><FONT SIZE=2>error at the serial read i/o box.  </FONT></P><P><FONT SIZE=2>Capture all the data read into a string, only clear the string after you</FONT><BR><FONT SIZE=2>have read the data.  Take your time to check the string, since you are</FONT><BR><FONT SIZE=2>getting the data from a serial port.  The advice below is pretty good, you</FONT><BR><FONT SIZE=2>can use the data available within your continuous read loop to only execute</FONT><BR><FONT SIZE=2>your read i/o when data is available, else just read and throw away the</FONT><BR><FONT SIZE=2>timeout error.  Make sure to remember to concate your data, example,</FONT><BR><FONT SIZE=2>"aString + [i/o data out]".  When done with the data, take care to clear the</FONT><BR><FONT SIZE=2>string, when not reading, i. e. aString = NULL, I use an empty TEXT box as a</FONT><BR><FONT SIZE=2>NULL.</FONT></P><P><FONT SIZE=2>Note that you will need to put some logic within your continuous read</FONT><BR><FONT SIZE=2>thread, that is, you will be able to set a global record field to inspect</FONT><BR><FONT SIZE=2>when you want to do som'n som'n within the read loop.  Typically for</FONT><BR><FONT SIZE=2>timeouts, I use 30 millisecond, 0.030, or so, but take care and watch that</FONT><BR><FONT SIZE=2>you do not drop data depending upon how you clear the string.  I clear the</FONT><BR><FONT SIZE=2>string when I know I am not receiving data.  Also note that you will need to</FONT><BR><FONT SIZE=2>parse the string to use the data.</FONT></P><P><FONT SIZE=2>You should not need to worry about writing to the same device while reading</FONT><BR><FONT SIZE=2>since there is a transmit and receive line.</FONT></P><BR><P><FONT SIZE=2>-----Original Message-----</FONT><BR><FONT SIZE=2>From: Schlieker, Reiner [<A HREF="mailto:reiner.schlieker@siemens.com">mailto:reiner.schlieker@siemens.com</A>] </FONT><BR><FONT SIZE=2>Sent: Thursday, April 29, 2004 3:56 PM</FONT></P><P><FONT SIZE=2>You could try putting a DAV object (Data available) before the read, so that</FONT><BR><FONT SIZE=2>a read is only attempted if there is data in the buffer.  This will avoid</FONT><BR><FONT SIZE=2>the program stopping when the read object errors due to no data in the</FONT><BR><FONT SIZE=2>buffer.</FONT></P><BR><P><FONT SIZE=2>-----Original Message-----</FONT><BR><FONT SIZE=2>From: Zhang, Dale [<A HREF="mailto:zhangd@tycoelectronics.com">mailto:zhangd@tycoelectronics.com</A>]</FONT><BR><FONT SIZE=2>Sent: Thursday, April 29, 2004 2:45 PM</FONT></P><P><FONT SIZE=2>I am attaching an example to show how I am trying to use the serial port to</FONT><BR><FONT SIZE=2>communicate with our device.</FONT></P><P><FONT SIZE=2>This runs well in my office PC for vee and vxe. But on our lab PC, vxe does</FONT><BR><FONT SIZE=2>not show any reading in the logging window, vee shows the readings some</FONT><BR><FONT SIZE=2>time. The bottom line is that write is good but read.</FONT></P><P><FONT SIZE=2>I talked to Agilent support, they thought that the cause is we do not have</FONT><BR><FONT SIZE=2>any handshaking. I agree. Software handshaking has drawback: decimal 17 and</FONT><BR><FONT SIZE=2>19 are now unavailable for data values. We can not use, while Hardware</FONT><BR><FONT SIZE=2>Handshaking needs more work. But is there any simpler solution? </FONT></P><P><FONT SIZE=2>I tried to add a delay between write and read in the driver, which did not</FONT><BR><FONT SIZE=2>solve the problem. When we do not get readings, I/O bus monitor does not</FONT><BR><FONT SIZE=2>show any readings too.</FONT></P>---<BR>You are currently subscribed to vrf as: rsb@soco.agilent.com<BR>To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".<BR>To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".<BR>To send messages to this mailing list,  email "vrf@agilent.com".  <BR>If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".</BODY></HTML>  

Outcomes