LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading from a serial port after power cycle

Hi,

     I've created an application that uses a power outlet that I can turn on and off over USB.  I use this controllable power outlet to power cycle various devices.  One of those devices is a computer.  The computer has a USB/UART connection over which I can read the computer's boot up sequence. 

 

I start with the PC powered up.  I use a VISA Configure Serial Port and then attempt to read from the port.  The first read shows me some of the data from the boot up sequence.  

 

I thought to close the serial port, power cycle the PC, configure the serial port again and try to read from the serial port again.  However, when I do that, I get an error from Configure Serial Port that something is wrong with the flow control settings of the port.

 

So, I tried to close the port, power cycle the PC, and then open the serial port again.  This time, I don't get errors when I open the port, but my attempts to read from the port return nothing.

 

Can anyone suggest what I might be doing wrong in this scenario?

 

Thanks,

 

Jason Mazzotta

0 Kudos
Message 1 of 9
(861 Views)

If you open a port while the connected device is sending something, it is likely your first read will have a framing error due to opening the port in the middle of a data byte.  Other hardware related errors are also common from shutting down and starting up devices.  I would just ignore the error on the first read and try reading again.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 9
(807 Views)

Thank you for your reply, crossrulz.  I cleared out the error from the first read, as well as from using Config Serial Port after power cycle.  

 

I then probed the VISA resource after power cycling and running Config Serial Port again.  The probe showed that the VISA resource was no longer valid.  So, I think using that more than once may be the problem.

0 Kudos
Message 3 of 9
(794 Views)

Probably you should close the serial port when you power cycle the computer.  You should be okay after that.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 9
(786 Views)

"Probably you should close the serial port when you power cycle the computer.  You should be okay after that."

 

"I thought to close the serial port, power cycle the PC, configure the serial port again and try to read from the serial port again.  However, when I do that, I get an error from Configure Serial Port that something is wrong with the flow control settings of the port."

 

I do close the serial port before configuring it again.  When I configure the port again, I get an error :

 

-1073807194 at Property Node ( arg 8 ) in VISA Configure Serial Port.

 

Possible reason:  The connection for the given session has been lost.

0 Kudos
Message 5 of 9
(778 Views)

I've run into "The connection for the given session has been lost" before. I found that when I closed the VISA, I was just closing the VISA alias that I used. I also had to close the associated VISA resource, which I got from the C:\ProgramData\National Instruments\NIvisa\visaconf.ini file. Once both of those are closed then reopening the VISA did not cause that error.

0 Kudos
Message 6 of 9
(767 Views)

Thank you.  I tried this and now the original VISA resource I was using is considered invalid when I try to reconfigure it?

 

0 Kudos
Message 7 of 9
(758 Views)

@jasonmaz wrote:

Thank you.  I tried this and now the original VISA resource I was using is considered invalid when I try to reconfigure it?

 


That sounds worse. Oh well maybe don't do that then.

0 Kudos
Message 8 of 9
(751 Views)

I think the problem I was having was that I started with the computer that I was trying to communicate and the power switch turned on.

 

When I started with both the power switch and the computer turned off, powered on the switch, opened the port and then tried to communicate, I was successful the first time.

 

The cycle was then:

 

close the COM port

power cycle the computer

open the COM port

read from COM port

 

and more often then not, I could see output streaming from the UART.

 

In any case, my communications with this computer are more consistently successful.  

 

Thanks!

0 Kudos
Message 9 of 9
(683 Views)