Post by sccl8998 on Dec 19, 2022 17:52:40 GMT
I am migrating a program from QBASIC to QB64 on windows 10. I am having trouble communicating with a device through a comport, and not confident that the signal is going out to the device. Has anyone had any issues using com ports in QB64? Or windows blocking QB64 on com ports?
9050 'serial communications with PFP
message$ = "com port to open not specified correctly!!"
opencom = 0
If stype$(sn) = "tank" Or stype$(sn) = "flask" Then
comport1$ = "Y"
Open "COM1:9600,N,8,1,ASC" For Random As #3
message$ = "serial port #1 OPEN"
opencom = 1
End If
If stype$(sn) = "tank2" Or stype$(sn) = "flask2" Then
comport2$ = "Y"
Open "COM2:9600,N,8,1,ASC" For Random As #3
message$ = "serial port #2 OPEN"
opencom = 1
End If
If Loc(3) > 0 Then 'clear buffer
TEMP$ = Input$(Loc(3), 3)
End If
Return
9055 'operate on flask package with directional flags
If pfptask$ = "pfpreply" Then GoSub 9090
If pfptask$ = "open" Then GoSub 9080
If pfptask$ = "close" Then GoSub 9085
If pfptask$ = "readpress" Then GoSub 9070: GoSub 9095
Return
9058 'looking for look$ in response buff$ from PFP
z = 1: GoSub 7700 'wait z loops (0.3 sec)
buff$ = Input$(Loc(3), 3)
j = InStr(buff$, look$)
Return
9060 ' get AS prompt
c = 0
Print #3, " "
look$ = asprmpt$: GoSub 9058 'look for AS>
9061 If j < 1 Then
Print #3, "Q": GoSub 9058
c = c + 1
If c = 4 Then message$ = "could not reach AS>": GoSub 9999
End If
If j < 1 And c < 4 Then GoTo 9061
message$ = "prompt now AS>"
Return
9090 'read reply from pfp
z = 1: GoSub 7800 'wait 1 sec, not 1 loop
If Loc(3) > 0 Then
buff$ = Input$(Loc(3), 3)
message$ = Mid$(buff$, 26, 32): GoSub 5800
If t > (postsec + 180) Then pfpopen$ = message$ 'save pre-sampling message
'problems indicated by "stalled" or "stuck"
If t < (postsec + 180) Then pfpclose$ = message$ 'save post-sampling message
'problems indicated by "stuck" or "broken"
Else message$ = "no reply from pfp": GoSub 5800
End If
Return
9095 ' read pressure in inlet of pfp package
'read during evac, save to Pevac
'read before sampling--conditional use of pneutronics possible!! save as Pinit
'read after sampling--final P in flask, save as Pfinal
' GOSUB 9070 'get unload'
z = 1: GoSub 7800 'wait 1 sec, not 1 loop...
If Loc(3) > 0 Then TEMP$ = Input$(Loc(3), 3)
Print #3, "P"
look$ = "now": GoSub 9058
pfppress$ = Mid$(buff$, j + 4, 9)
message$ = pfppress$: GoSub 5800
Return
10000 'convert pfppress$ to numeric
look$ = "."
j = InStr(pfppress$, look$)
Pval = Val(Left$(pfppress$, j + 1))
Return
9050 'serial communications with PFP
message$ = "com port to open not specified correctly!!"
opencom = 0
If stype$(sn) = "tank" Or stype$(sn) = "flask" Then
comport1$ = "Y"
Open "COM1:9600,N,8,1,ASC" For Random As #3
message$ = "serial port #1 OPEN"
opencom = 1
End If
If stype$(sn) = "tank2" Or stype$(sn) = "flask2" Then
comport2$ = "Y"
Open "COM2:9600,N,8,1,ASC" For Random As #3
message$ = "serial port #2 OPEN"
opencom = 1
End If
If Loc(3) > 0 Then 'clear buffer
TEMP$ = Input$(Loc(3), 3)
End If
Return
9055 'operate on flask package with directional flags
If pfptask$ = "pfpreply" Then GoSub 9090
If pfptask$ = "open" Then GoSub 9080
If pfptask$ = "close" Then GoSub 9085
If pfptask$ = "readpress" Then GoSub 9070: GoSub 9095
Return
9058 'looking for look$ in response buff$ from PFP
z = 1: GoSub 7700 'wait z loops (0.3 sec)
buff$ = Input$(Loc(3), 3)
j = InStr(buff$, look$)
Return
9060 ' get AS prompt
c = 0
Print #3, " "
look$ = asprmpt$: GoSub 9058 'look for AS>
9061 If j < 1 Then
Print #3, "Q": GoSub 9058
c = c + 1
If c = 4 Then message$ = "could not reach AS>": GoSub 9999
End If
If j < 1 And c < 4 Then GoTo 9061
message$ = "prompt now AS>"
Return
9090 'read reply from pfp
z = 1: GoSub 7800 'wait 1 sec, not 1 loop
If Loc(3) > 0 Then
buff$ = Input$(Loc(3), 3)
message$ = Mid$(buff$, 26, 32): GoSub 5800
If t > (postsec + 180) Then pfpopen$ = message$ 'save pre-sampling message
'problems indicated by "stalled" or "stuck"
If t < (postsec + 180) Then pfpclose$ = message$ 'save post-sampling message
'problems indicated by "stuck" or "broken"
Else message$ = "no reply from pfp": GoSub 5800
End If
Return
9095 ' read pressure in inlet of pfp package
'read during evac, save to Pevac
'read before sampling--conditional use of pneutronics possible!! save as Pinit
'read after sampling--final P in flask, save as Pfinal
' GOSUB 9070 'get unload'
z = 1: GoSub 7800 'wait 1 sec, not 1 loop...
If Loc(3) > 0 Then TEMP$ = Input$(Loc(3), 3)
Print #3, "P"
look$ = "now": GoSub 9058
pfppress$ = Mid$(buff$, j + 4, 9)
message$ = pfppress$: GoSub 5800
Return
10000 'convert pfppress$ to numeric
look$ = "."
j = InStr(pfppress$, look$)
Pval = Val(Left$(pfppress$, j + 1))
Return