Question Locked

Com port issue

0 helpful
8 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm using QuickBasic 3.0 to read a scanner on a serial port (Com1) using XP SP2. I recently added a shell out to DOS to run a Visual Basic program. I can scan a barcode fine, but now when I return after the shell to the XP DOS emulator, my com port gives me and error 68, "DEVICE UNAVAILABLE ERR 68". What I can find says that SP2 closes the com port when not in use. I can scan multiple times without errors if I don't SHELL to DOS.

I know this is old school stuff, but it's what this old system uses.

Any suggestions as to how to fix this ?

8 replies

by mjd420nova

As long as the port gets opened again when you run back to the shell, the error doesn't really hurt anything. But if you have to reboot to get past the error, that can be a headache.

by fred123456

WOW! QBasic!! Give me nibbles or give me death! LOL

I don't think your going to be ablle to get around this unless you delve deep in to the OS and find out what exactly XP does to open the comm port and send that command to the port itself if possible, when you need to scan again.

by gblattner

I have checked into it a while and it looks like XP ServicePack 2 closes the comm ports to stop hackers from getting into the system on ports left open.

The thing is that I can scan and open and close the port all day until I shell to another DOS session. When I return from that and I try to open the comm port, the comm port errors out.

It's like the DOS emulator looses it's visibility to the comm port. So I think I need to somehow show DOS that it's still there....

by fred123456

May have to write your own QB version of a refresh to rescan all the ports?

Actually grasping at straws here its been to long.. (GRIN)

Just to clarify, you keep mentioning the DOS emulator, are you using the system created NTVDM or are you using an after market emulator to run the code?

by gblattner

I use the XP version of DOS which uses the NTVDM.

by bsmith523

Its been a while but if I remember right, comm ports are opened using handles like files. Is your QB routine closing com1 (i.e. releasing the handle) after the scanner is done scanning each time or does it leave the port open until you close the program? If it is leaving it open then when you close the DOS shell it closes any open comm ports. If this is the case you will need to modify the QB program to open and close the port for each scan. Otherwise just don't close the DOS window after you open it.

This discussion is closed to new replies.