Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a QB COM program and it errors...

Status
Not open for further replies.

TMGBrian

Programmer
Feb 6, 2002
6
US
Every once in a while, I open a QBasic program, it freezes. It flashes an error message so fast its unreadable. I then must restart my computer and hope it works when it restarts. Ive tried all versions QB and it still does it. My boss at my company, says it has something to do with the com port and when it loads up, it checks the com port state and it errors. The program is designed to talk to Motion Controllers that I build and the program works 90% of the time. The odd thing is that we've only had about 2 customers out of a 100 that experience the same issue. Any help? Thanks in advance.
 
I had a similar problem with an earlier computer (a 286). I could open the com port only once. If I stopped the prog and then ran it again there was a com error. The only answer was to switch off and try agin. All was then OK.
Is that the problem you've got?
 
Nope. Once the computer is on and it works one time, it works until I shut off the Computer and restart it. Sometimes it doesnt work at all. not even once. So I have to constantly restart my computer. Could it be the program thats doing it? Or just the COM port itself? thanks.
 
All I could suggest is you might measure voltage at the Data Out com pin to see if the port has been opened. If that is correct it would confirm that bit of the port was OK. It might be the control lines CTS, RTS etc are not as they should be and your prog is waiting. Other than that I cannot help.
 
Hey thanks. My boss tried that, and he said it still doesnt work. I dont know, but thanks anyways. Anyone else have any suggestions?
 
Could you post the bit of code that opens the com port?
 
Sorry its so Late, Ive been terribly busy and have had no time to respond. But here it is, better late than never :). Thanks again for the help.

140 OPEN "COM1:9600,N,8,1,CS000,DS0,CD0" FOR RANDOM AS #1: REM CS SET TO 0 SEC
141 PRINT #1, CR$; CR$; : REM SEND AUTOBAUD CARRIAGE RETURNS TO COM 1
142 PRINT #1, "O 0A0H": REM SET MODE COMMAND-AUTOMATIC BUSY FUNCTION-ARM BIT 6
143 CLOSE #1
144 OPEN "COM1:9600,N,8,1,CS1000,DS0,CD0" FOR RANDOM AS #1: REM CS SET TO 1 SEC
145 PRINT #1, CR$; CR$; : REM SEND AUTOBAUD CARRIAGE RETURNS TO COM 1

 
I can make two suggestions:

1. Your line 140 has no delay on CS,DS or CD. If the status of those lines is not correct when you open the com port, you will get a timeout error. Setting each to a delay of 1sec may do the trick.

2. As, presumably, you wrote the program, how about putting in a temporary ON ERROR sub that put the error number on the screen. That would point you in the right direction.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top