Question

Locked

Com port issue

By gblattner ·
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 ?

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

DOS

by mjd420nova In reply to Com port issue

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.

Collapse -

OMG!

by Fred123456 In reply to Com port issue

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.

Collapse -

yes, but.....

by gblattner In reply to OMG!

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....

Collapse -

Brain dumping

by Fred123456 In reply to yes, but.....

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?

Collapse -

just dumb ol DOS

by gblattner In reply to Brain dumping

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

Collapse -

I'm actually gonna suggest a PIF file!?!?!

by Fred123456 In reply to just dumb ol DOS

I can't beleave I'm gonna say this but you may have to create a pif file that tells XP how to handle things.. The NTVDM is still pretty much unchanged and can still use them.

Check out the Technet article on how to create and it may help..

Their also links at the bottom that may help also.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/windows_dos_configure.mspx?mfr=true

Collapse -

QBasic

by bsmith523 In reply to Com port issue

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.

Back to Networks Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums