blah blah blah is here! blah blah » Close

up0down
link

Hi All,

I am in the process of writing a programming and test rig for some boards and have noticed an oddity. Some boards have been presumably damaged and when I try to test them the program hangs. My thought was well it can't open the serial port as it has been damaged so that is whats hanging the program. I am testing if the port can be opened using

if(!(DUTCommPort.IsOpen))
{
Messagebox.Show("DUT Not Open!");
}

this is not happening which means either the comm ports are getting ignored by windows and something else is jumping in or I am not using .IsOpen correctly (or else something else is happening all together) I have tried to use a timer to get get out of this but it too gets lost in the program not responding meaning something has broken or is there a bug??

I know this is a little hard to answer with out seeing all the code, but HELP!

Glenn

last answered one year ago

1 answers

up1down
link

Well, if I can start by stating the obvious (which sometimes helps in these matters!), if the Open() method has been called on the port without any exception being thrown and the Close() method hasn't been called in the meantime, then the IsOpen property should return true.

So, if IsOpen is returning false, then there must have been a hardware or device driver failure since the port was opened, which has caused the OS to shut it down.

If the program is hanging, then the hardware or device driver failure must be so serious that it has destabilized the process's threads. So, your initial thought that the board has been damaged may well be correct.

GlennP
329

Hmm, Is it possible to get out of this situation as I have tried using a timer to indicate that there is problem but from your answer it shows that because of the thread falling over this gets taken out too. Is there a way of seeing if the port has opened and then closed with out taking out the tread?? Glenn

vulpes
17279

If you're trying to ascertain whether or not a board is misfunctioning, I'd write the simplest possible application to test it (namely a single threaded console application) and use Thread.Sleep rather than a timer to create a delay between successive retests of the IsOpen property. That way, if there is a problem, you can be much more certain that it's caused by the board and not by the program itself.

GlennP
329

Hi, Been there done that the customer says "can you make a version of that in Windows", boss says "Yes" I get sleepless nights! enough of a rant, I take it that if my Windows program runs the Dos app the Dos app is going to be on a different thread and this is the one which will fall apart not the Apps thread? Glenn

vulpes
17279

If you launch a DOS or Win32 console application which does serial port communication from a windows Forms application then, yes, the former will run under a separate process and it will be that process which may hang if there's a hardware or driver problem. The Windows Forms application itself should be unaffected unless, of course, it's waiting for the child process to end.

Feedback