Board index » cppbuilder » USB Comm Port

USB Comm Port


2006-03-28 07:08:19 PM
cppbuilder44
Hello All
I program with Borland C++ 5.02, on Windows XP.
I've written a lot of code to communicate with Serial Comm ports, & my
programs have been used for many years now.
When I use a USB Port (Prolific USB to Serial Comm Port), it appears to work
normally (reading in data from a connected PC), allowing me to exit the
program normally.
But then, perhaps a minute later, a major error occurs, which shuts the PC
down.
The message fills the screen, mentioning:-
Page fault in Non-paged area.
Stop : 0x00000050 (), etc.
Please could anyone advise why this might occur,
and in what way USB Comm Ports may differ in functionality from normal Comm
Ports?
Thanks,
Regards Al
 
 

Re:USB Comm Port

Hi Al,
"A Davis" < XXXX@XXXXX.COM >wrote in message
Quote

Please could anyone advise why this might occur,
and in what way USB Comm Ports may differ in functionality from normal
Comm Ports?

I have no experience with Prolific, but I have used a Keyspan USB device
that supplied 4 serial ports.
The emulation was perfect, even all the hardware lines behaved as if real
UARTS were present in the PC.
The problem is the fact that you are dependent on the device driver and
firmware that the vendor supplies.
If they cause instability, there is very little you can do yourself, except
complain to the vendor.
I have experienced no such instability with the Keyspan device, this was on
W2K.
HTH, Matt
 

Re:USB Comm Port

A Davis wrote:
Quote
Please could anyone advise why this might occur,
Do you close the ports properly?
Thinking the driver might not know you are gone, and try to
communicate with you.
Wondering if the vendor has a web site with documentation on the
proper usage of it's product?
Quote
and in what way USB Comm Ports may differ in functionality from normal Comm
Ports?
Main difference would be an extra driver.
I agree with Mat in general (though have never used USB/Serial).
Have you checked for updated drivers?
 

{smallsort}

Re:USB Comm Port

Matt Claessen wrote:-
<<If they cause instability, there is very little you can do yourself,
except complain to the vendor.>>
But the problem doesn't occur when using HyperTerminal, so I want to check
all possibilities before blaming the vendor.
Regards Al.
 

Re:USB Comm Port

Bob Gonder wrote:-
<<Do you close the ports properly?>>
I always thought so, by calling:-
PurgeComm(hCom,PURGE_RXCLEAR | PURGE_TXCLEAR);
CloseHandle(hCom);
The helpfile mentioned a function called CancelIO(hCom), but this was never
recognised by the compiler, so I left it.
(I just found out that this was a typo in the helpfile, so can now actually
call this function.
But it doesn't resolve the problem mentioned, so I choose to leave it out).
But it's this kind of Trial and Error situation which is the problem for me.
Comms really is a nightmare IMO. To read from the port, I found some sample
code years ago.
It always seems over complex, setting up an event with CreateEvent(), using
OVERLAPPED structures, GetCommTimeouts(), etc.
I make sure I call CloseHandle(EventHandle) in my CommsRead() function.
But there seem to be so many places for possible errors.
Is there some good sample code showing the correct way to read a serial
comms port synchronously?
(By 'synchronously' I mean there may or may not be any data coming in, so I
can't wait around in my CommsRead() function.)
Thanks again,
Regards Al.
 

Re:USB Comm Port

Hi,
"A Davis" < XXXX@XXXXX.COM >wrote in message
Quote
But the problem doesn't occur when using HyperTerminal, so I want to check
all possibilities before blaming the vendor.

I would take this one step at a time to isolate the problem.
Try your code on a real serial port first.
If the problem is in your code, one would expect the problem to appear there
too.
There is a good serial comms sample on the microsoft site, called mttty
msdn.microsoft.com/library/default.asp
I have always preferred to use a third party solution myself, especially
since I found out that you have to use multithreading in Windows 9x for
reliable results.
I found out that serial comms in Windows NT and up are a lot easier to
reliably program.
HTH, regards, Matt
 

Re:USB Comm Port

A Davis wrote:
Quote
Comms really is a nightmare IMO. To read from the port, I found some sample
code years ago.
It was easier in the pre-Windows era when you talked directly to the
USART.
Quote
It always seems over complex, setting up an event with CreateEvent(), using
OVERLAPPED structures, GetCommTimeouts(), etc.
Yeah, that's why I prefer blocking calls, just different threads for
reading, writting, and using.