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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serial msComm1 does not see EOF

Status
Not open for further replies.

rjmccorkle

Programmer
Aug 26, 2000
55
US
I am writing a VB6 program to allow file transfers between a CNC machine and a computer. The From CNC To Commputer part doesn't work. The code I used in GWBasic that I can't replicate in VB is the subroutine at line 350:

270 PRINT:pRINT" HIT INPUT KEY ON CNC NOW..."
280 OPEN BC$ AS #1:OPEN "O",2,F$:pRINT#1,CHR$(13);
295 A$=INPUT$(1,#1):pRINT A$;:LINE INPUT#1,A$:pRINT A$;:A$=INPUT$(1,#1)
300 IF EOF(1) THEN GOSUB 350
310 IF LOC(1)>128 THEN PAUSE=TRUE:pRINT#1,XFF$;
320 A$=INPUT$(LOC(1),#1):pRINT#2,A$;:pRINT A$;:IF LOC(1)>0 THEN 310
330 IF PAUSE THEN PAUSE=FALSE:pRINT#1,XN$;
335 GOTO 300
350 FOR I=1 TO VF:IF NOT EOF(1) THEN I=999999!
352 IF LOC(1)>100 AND I<999999! THEN:A$=INPUT$(LOC(1),#1):pRINT#2,A$;:pRINT A$;
355 NEXT I:IF I>999999! THEN RETURN
360 CLOSE:RETURN 20

Variable VF in the For/Next loop is a timing variable that is changed based on CPU speed.
In VB I have the MSComm1.EOFEnabled=True but it never is triggered, the CommEvent is always 2. Apparently the CNC sends over things that look like EOF but are not the actual EOF, hence the need for double checking in the 350 subroutine. When I run my VB code I get 2 good chunks of data about 300 bytes each, but at the end of the 3rd chunk, question marks start coming through. I'm using Xon/Xoff to try to control the flow (chr(17) & chr(19)). Here are some of the property values I am using:
MSComm1.NullDiscard = True
MSComm1.EOFEnable = True
MSComm1.Break = True
MSComm1.InputLen = 1
MSComm1.RThreshold = 1
MSComm1.InputMode = comInputModeText

I checked the SaxSoft comm control but it was a little too expensive as long as the GWBasic code works for us.
Any help would be appreciated.
Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top