<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: VISA Serial Write is not writing in LabVIEW</title>
    <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085177#M1175673</link>
    <description>&lt;P&gt;Are you trying to run the serial monitor the same time you are running your VI?&amp;nbsp; I don't think that would work as the PC would be conflicting on serial ports.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you put in a visual indicator such as turning on an LED when it has Serial.Available?&amp;nbsp; Wait 500 milliseconds.&amp;nbsp; Then in the Else section of Serial.Available, turn off the LED.&amp;nbsp;&amp;nbsp; Then you should see the LED blink when it receive a character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you say other VI's work with the same Arduino and this one doesn't, you need to figure out what is the difference between the ones that work and this one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should delete your serial controls.&amp;nbsp; You have a lot of coercion dots because you used doubles.&amp;nbsp; Most of those should probably be constants anyway.&lt;/P&gt;
&lt;P&gt;Delete the control, write click on the input and pick Create Constant.&amp;nbsp; Edit the value to what is needed.&amp;nbsp; Now you'll have the correct datatype.&lt;/P&gt;</description>
    <pubDate>Tue, 22 Sep 2020 18:25:44 GMT</pubDate>
    <dc:creator>RavensFan</dc:creator>
    <dc:date>2020-09-22T18:25:44Z</dc:date>
    <item>
      <title>VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085122#M1175641</link>
      <description>&lt;P&gt;I'm doing a very simple serial read-write VI with an Arduino just to figure out how to do some error handling for a more complicated project. I have a very minimal Arduino code that just instructs the Arduino to return the byte it received unless that byte is a '1', in which case it does nothing (this is to test if my code can catch and correct a read timeout). I know this Arduino code is working; I've verified it using the the serial moniter and another, previously written VI.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The VI I have here should be the easiest thing possible to get working; it just sends a single byte, reads the response, then if there's an error code it executes a case structure. I have determined, through some testing on the Arduino, that the VISA serial write function is not writing anything to the Arduino. I always end up with a VISA read timeout because the Arduino is not receiving any message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm totally baffled here, I have much more complicated VI's sending the same types of messages to the same Arduino (with the exact same Serial configuration) and reading back actual data, I cannot for the life of me figure out why this one isn't doing anything. Is there something going on here that I don't know?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 16:12:12 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085122#M1175641</guid>
      <dc:creator>Tarnarmour</dc:creator>
      <dc:date>2020-09-22T16:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085144#M1175652</link>
      <description>&lt;P&gt;Your question is missing the Arduino part.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LabVIEW you are sending a 2.&amp;nbsp; (What makes you think it is not being sent?)&lt;/P&gt;
&lt;P&gt;The Arduino has some code that isn't shown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You say it is working, but how do WE know it is?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure your LabVIEW communication settings match the Arduino's?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 16:52:55 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085144#M1175652</guid>
      <dc:creator>RavensFan</dc:creator>
      <dc:date>2020-09-22T16:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085150#M1175656</link>
      <description>&lt;P&gt;Are you sure you are not getting some other error?&amp;nbsp; Are you trying to run this VI while also using the Arduino serial monitor or some other code?&amp;nbsp; Are you sure your Baud Rate is correct?&amp;nbsp; How about the other settings?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As already stated, we need to see the Arduino code as well in order to help debug this.&amp;nbsp; Is the Arduino using the println or the print in order to send back the read byte.&amp;nbsp; If using print, then you will definitely get timeouts because you told the VISA Read to read up to 100 bytes, ending with the termination character.&amp;nbsp; But if the Arduino is not sending the termination character, the VISA Read will time out.&amp;nbsp; Instead, you need to tell the VISA Read to read 1 byte.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also really need to clean up your diagram, including using actual Error Clusters instead of unbundling the parts.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://forums.ni.com/ni/attachments/ni/170/1175656/1/SerialTimeoutDevel_BD.png" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 17:10:16 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085150#M1175656</guid>
      <dc:creator>crossrulz</dc:creator>
      <dc:date>2020-09-22T17:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085169#M1175668</link>
      <description>&lt;P&gt;Sorry for not including Arduino code earlier:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;char inChar = '6';

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  if (Serial.available()) {
    inChar = Serial.read();

    if (inChar == '1') {
      Serial.println("test?");
    }
    else {
      Serial.println(inChar);
    } 
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is very slightly different than what I described before, the only difference being that now a '1' being received will cause the Arduino to print "test?".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The settings for the VISA connection are identical to another more complicated VI I wrote previously which connects to this same Arduino. That VI usually reads data off a sensor attached to the Arduino, and works correctly. If I load the above program to the Arduino and use this other VI, it works as expected (some other errors occur because it recieves the word "test?" when it's expecting a string with a float value, but other than this the program works, and most relevantly the write and read functions work).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my evidence that the Arduino code works, and that the write function is the problem:&lt;/P&gt;
&lt;P&gt;1) Using the Arduino serial monitor, I can send Serial messages to the Arduino and it responds as expected&lt;/P&gt;
&lt;P&gt;2) Using another VI with this same Arduino running this same code I receive the expected output&lt;/P&gt;
&lt;P&gt;3) I tried a modified version of this Arduino code that would continuously print the first message it received. After running the problematic VI I checked the Arduino using the Arduino Serial monitor and found that it had received no message&lt;/P&gt;
&lt;P&gt;4) I have been successfully using another VI with this same Arduino, using the same Serial settings, to read data off of other devices&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've attached the other VI in case it's helpful.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 18:07:00 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085169#M1175668</guid>
      <dc:creator>Tarnarmour</dc:creator>
      <dc:date>2020-09-22T18:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085173#M1175671</link>
      <description>&lt;P&gt;I am certain I am receiving a timeout error, I'm looking at the actual error code. I am just learning how to use error clusters today, this VI is just a very simple way to explore them and figure out how they work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Arduino is using println, I am using the termination character to indicate the end of the message. As I mentioned I've used virtually the same write/read code in another VI and it's working (incidentally it was another question that you helped answer that saved me from the bytesAvailable mess, so it'd all be a lot worse without that! Thanks!), I've attached that VI to another reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a side note, do you have any specific advice on how to clean up my Labview code? I'm very knew and I definitely know I'm not writing things in a very efficient or clean way, so I'd appreciate any style tips or general corrections. Specifically do you have a link to anything describing what you meant with the error clusters? I did some googling on them earlier to work out what I have in my VI but I don't know what functions you are using in this cleaned up example, nor what the proper way to use them was. I've been unbundling them because I wanted to figure out what the actual messages were and because they feel easier to work for a newbie as more recognizable data types. Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 18:15:47 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085173#M1175671</guid>
      <dc:creator>Tarnarmour</dc:creator>
      <dc:date>2020-09-22T18:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085177#M1175673</link>
      <description>&lt;P&gt;Are you trying to run the serial monitor the same time you are running your VI?&amp;nbsp; I don't think that would work as the PC would be conflicting on serial ports.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you put in a visual indicator such as turning on an LED when it has Serial.Available?&amp;nbsp; Wait 500 milliseconds.&amp;nbsp; Then in the Else section of Serial.Available, turn off the LED.&amp;nbsp;&amp;nbsp; Then you should see the LED blink when it receive a character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you say other VI's work with the same Arduino and this one doesn't, you need to figure out what is the difference between the ones that work and this one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should delete your serial controls.&amp;nbsp; You have a lot of coercion dots because you used doubles.&amp;nbsp; Most of those should probably be constants anyway.&lt;/P&gt;
&lt;P&gt;Delete the control, write click on the input and pick Create Constant.&amp;nbsp; Edit the value to what is needed.&amp;nbsp; Now you'll have the correct datatype.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 18:25:44 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085177#M1175673</guid>
      <dc:creator>RavensFan</dc:creator>
      <dc:date>2020-09-22T18:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085181#M1175676</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/659606"&gt;@Tarnarmour&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;As a side note, do you have any specific advice on how to clean up my Labview code? I'm very knew and I definitely know I'm not writing things in a very efficient or clean way, so I'd appreciate any style tips or general corrections. Specifically do you have a link to anything describing what you meant with the error clusters? I did some googling on them earlier to work out what I have in my VI but I don't know what functions you are using in this cleaned up example, nor what the proper way to use them was. I've been unbundling them because I wanted to figure out what the actual messages were and because they feel easier to work for a newbie as more recognizable data types. Thanks for the help!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It's a little old (2007), but this book is an excellent read: &lt;A href="https://www.amazon.com/LabVIEW-Style-Paperback-Peter-Blume/dp/0134878426/ref=sr_1_1?crid=2GJ2CTOWDD19U&amp;amp;dchild=1&amp;amp;keywords=the+labview+style+book&amp;amp;qid=1600799466&amp;amp;sprefix=The+LabVIEW+Style%2Caps%2C405&amp;amp;sr=8-1" target="_blank" rel="noopener"&gt;The LabVIEW Style Book&lt;/A&gt; by Peter Bloome.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 18:33:51 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085181#M1175676</guid>
      <dc:creator>crossrulz</dc:creator>
      <dc:date>2020-09-22T18:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085187#M1175681</link>
      <description>&lt;P&gt;I am not running the monitor at the same time, when I've referred to checking the monitor what I mean is that I run the VI to completion, then open the serial monitor and query the Arduino (as I mentioned, I had a modified code that would cause the Arduino to constantly print whatever the last thing it read was, to see if it was the Write function that was the issue).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The VI with the doubles was a much earlier VI I wrote when I was trying to figure out how to use Serial reading. I had them all as inputs because I wanted to be able to experiment with how the Serial comms worked, and at the time I wasn't as aware of the datatype conflicts. I know it's in bad style, but my point is that that VI is the working one; the much cleaner, neater VI (which as far as I can tell is identical in every respect except for using constants and ints when initializing the Serial connection) is the one that is not working. I'm not really looking to improve the old one, I don't use it for anything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried your LED indicator idea (I forgot I had an LED lying around! Getting rusty when it comes to circuit debugging) and it confirms that there is no message being received during the VI running. If I use the Serial monitor to write something to it, the LED lights properly.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 18:56:17 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085187#M1175681</guid>
      <dc:creator>Tarnarmour</dc:creator>
      <dc:date>2020-09-22T18:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085190#M1175683</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/75897"&gt;@crossrulz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/659606"&gt;@Tarnarmour&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;As a side note, do you have any specific advice on how to clean up my Labview code? I'm very knew and I definitely know I'm not writing things in a very efficient or clean way, so I'd appreciate any style tips or general corrections. Specifically do you have a link to anything describing what you meant with the error clusters? I did some googling on them earlier to work out what I have in my VI but I don't know what functions you are using in this cleaned up example, nor what the proper way to use them was. I've been unbundling them because I wanted to figure out what the actual messages were and because they feel easier to work for a newbie as more recognizable data types. Thanks for the help!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It's a little old (2007), but this book is an excellent read: &lt;A href="https://www.amazon.com/LabVIEW-Style-Paperback-Peter-Blume/dp/0134878426/ref=sr_1_1?crid=2GJ2CTOWDD19U&amp;amp;dchild=1&amp;amp;keywords=the+labview+style+book&amp;amp;qid=1600799466&amp;amp;sprefix=The+LabVIEW+Style%2Caps%2C405&amp;amp;sr=8-1" target="_blank" rel="noopener"&gt;The LabVIEW Style Book&lt;/A&gt; by Peter Bloome.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I read it front to back.&amp;nbsp; Bob Schor said he read it front to back 3x.&amp;nbsp; It was my bible before I developed my own style (based quite a bit on the book).&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 19:04:07 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085190#M1175683</guid>
      <dc:creator>billko</dc:creator>
      <dc:date>2020-09-22T19:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085193#M1175684</link>
      <description>&lt;P&gt;It sounds like a good resource but to be honest I really don't want to drop $100 on it, I'm not sure how long I'll be using LabVIEW in this current job but I will not be able to justify purchasing this with company money, and I don't really want to use it for personal use (I really prefer traditional non-visual coding languages, though I fully admit this may mostly be due to lack of experience and poor style habits). Do you know if there's anything similar (if less thorough) available online? Or even just some threads here going over some basic rules that you think are particularly good?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 19:11:20 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085193#M1175684</guid>
      <dc:creator>Tarnarmour</dc:creator>
      <dc:date>2020-09-22T19:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085224#M1175696</link>
      <description>&lt;P&gt;To be honest, most topics like this end up saying "go buy the book".&amp;nbsp; The reason why is that the book goes in-depth as to &lt;EM&gt;why&lt;/EM&gt; you should do the things it says to do.&amp;nbsp; This is a great example of "you get what you pay for".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That being said, &lt;A href="http://zone.ni.com/reference/en-XX/help/371361R-01/lvdevconcepts/checklist/" target="_blank" rel="noopener"&gt;something like this&lt;/A&gt; might be of more use to you.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 19:56:39 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085224#M1175696</guid>
      <dc:creator>billko</dc:creator>
      <dc:date>2020-09-22T19:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085227#M1175699</link>
      <description>&lt;P&gt;That is exactly what I was looking for, thanks a ton!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 20:01:20 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085227#M1175699</guid>
      <dc:creator>Tarnarmour</dc:creator>
      <dc:date>2020-09-22T20:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085321#M1175743</link>
      <description>&lt;P&gt;Hi Tarnarmour,&lt;/P&gt;
&lt;P&gt;Is your problem got resolved?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 04:20:12 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085321#M1175743</guid>
      <dc:creator>srikrishnaNF</dc:creator>
      <dc:date>2020-09-23T04:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085647#M1175868</link>
      <description>&lt;P&gt;No, unfortunately I still have no idea why the VISA write is not working. But I'm plugging away at it, we'll see.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 19:57:49 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085647#M1175868</guid>
      <dc:creator>Tarnarmour</dc:creator>
      <dc:date>2020-09-23T19:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085676#M1175879</link>
      <description>&lt;P&gt;I've figured something out. I put the whole thing I had there into a while loop, and things started working on the second or third iteration. After figuring that out I tried putting a delay after I connect to the Arduino, and I found that if I delay for any less than 1.7 seconds the write VISA just won't write (and, importantly, it doesn't seem to know that it has failed to write, or perhaps it is writing and the COM connection doesn't realize that it's not ready...) but any more than 1.7 seconds and everything seems to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this typical? Is there a more clean way of delaying until the COM port is ready? I feel like a set delay like this is not only ugly and maybe slower than necessary, it's also not very secure. This is going to be in a medical device so I'd like it to be more robust.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd appreciate any help, I feel way out of my depth here with this stuff.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 21:02:11 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085676#M1175879</guid>
      <dc:creator>Tarnarmour</dc:creator>
      <dc:date>2020-09-23T21:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085681#M1175881</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/659606"&gt;@Tarnarmour&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I've figured something out. I put the whole thing I had there into a while loop, and things started working on the second or third iteration. After figuring that out I tried putting a delay after I connect to the Arduino, and I found that if I delay for any less than 1.7 seconds the write VISA just won't write (and, importantly, it doesn't seem to know that it has failed to write, or perhaps it is writing and the COM connection doesn't realize that it's not ready...) but any more than 1.7 seconds and everything seems to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this typical? Is there a more clean way of delaying until the COM port is ready? I feel like a set delay like this is not only ugly and maybe slower than necessary, it's also not very secure. This is going to be in a medical device so I'd like it to be more robust.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd appreciate any help, I feel way out of my depth here with this stuff.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Apparently not SO much out of your depth, because your feelings are spot-on!&amp;nbsp; Needing a hard-coded time delay when communicating with an instrument is usually a sure sign that you have an incomplete understanding of how to communicate with the instrument.&amp;nbsp; This almost surely &lt;EM&gt;will&lt;/EM&gt; lead to problems with communications down the road, and definitely should be addressed.&amp;nbsp; You are also correct that waiting a set amount of time usually means time wasted because all your code should be doing is waiting for the message to show up, not waiting X seconds and then checking to see if a message arrived.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, I still can't offer you a solution, just an assurance that you are on the right track.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 21:25:02 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085681#M1175881</guid>
      <dc:creator>billko</dc:creator>
      <dc:date>2020-09-23T21:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085691#M1175886</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/659606"&gt;@Tarnarmour&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I've figured something out. I put the whole thing I had there into a while loop, and things started working on the second or third iteration. After figuring that out I tried putting a delay after I connect to the Arduino, and I found that if I delay for any less than 1.7 seconds the write VISA just won't write (and, importantly, it doesn't seem to know that it has failed to write, or perhaps it is writing and the COM connection doesn't realize that it's not ready...) but any more than 1.7 seconds and everything seems to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this typical? Is there a more clean way of delaying until the COM port is ready? I feel like a set delay like this is not only ugly and maybe slower than necessary, it's also not very secure. This is going to be in a medical device so I'd like it to be more robust.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd appreciate any help, I feel way out of my depth here with this stuff.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The reason for the delay is easy.&amp;nbsp; The Arduino is meant to be user-friendly out-of-the-box.&amp;nbsp; Notice how nice it is to plug in the USB cable and then program it and communicate with it?&amp;nbsp; We can thank the bootloader for that.&amp;nbsp; Also, isn't it nice that you don't have to power-cycle or push any buttons to reprogram it?&amp;nbsp; To accomplish this, it was decided that the board should reset every time the USB serial port is opened.&amp;nbsp; The board waits a bit to see if the signal comes to tell it that you want to flash a new program, otherwise it proceeds to the bootloader.&amp;nbsp; The reason for the delay is that every time you open the serial connection, the board resets, pauses, and then runs the bootloader.&amp;nbsp; This can take 1-7 seconds depending the the board and software version.&amp;nbsp; In your case it takes 1.7 seconds.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What can you do?&amp;nbsp; A few things.&amp;nbsp; You can put a capacitor on the reset line to hold the voltage and prevent the reset.&amp;nbsp; Not an elegant solution.&amp;nbsp; A more robust solution than waiting a fixed time is to put a serial write in the arduino startup code and have LV wait to receive this message before proceeding.&amp;nbsp; The downside here is that you have to be super careful that you actually close the VISA session.&amp;nbsp; If you abort without closing the port, the next time you run the open will be a no-op since LV already has the port open, and there will be no reset and no message sent.&amp;nbsp; For this reason, If I do not receive the startup message, then I will close the port, re-open, and try again.&amp;nbsp; Works well with my Firmata library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The best solution I can think of is also in your long-term interest IMO.&amp;nbsp; Dump the bootloader and program it using an ICSP (can actually use a second Arduino for this).&amp;nbsp; The reset is still there, but without the bootloader the restart is very quick, practically instantaneous.&amp;nbsp; I would personally not ship a medical device with a bootloader.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 22:18:26 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085691#M1175886</guid>
      <dc:creator>Darin.K</dc:creator>
      <dc:date>2020-09-23T22:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: VISA Serial Write is not writing</title>
      <link>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085708#M1175896</link>
      <description>&lt;P&gt;Okay, this makes sense now, thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After doing a bit of googling, I agree that using ICSP sounds like the best long term option. Hooray, another couple dozen hours of googling and frustration ahead &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 23:42:28 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/VISA-Serial-Write-is-not-writing/m-p/4085708#M1175896</guid>
      <dc:creator>Tarnarmour</dc:creator>
      <dc:date>2020-09-23T23:42:28Z</dc:date>
    </item>
  </channel>
</rss>

