Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coms port and RAM disk
#2
Yes, serial adapters over usb work fine in QB64pe.
Below the functions I created for this

Code: (Select All)
Errhandler: ' needed for ser.open% (ser$)
errorNum = Err: Resume Next

Function ser.open% (ser$)
  On Error GoTo Errhandler
  Open ser$ + ",N,8,1,BIN,CS0,DS0,RB8192" For Random As #88
  If errorNum = 0 Then serBytes$ = ser.read$
  On Error GoTo 0
  ser.open% = errorNum
End Function

Function ser.close$ ()
  ser.close$ = ser.read$
  Close #88
End Function

Sub ser.send (bytes$)
  Dim b As String * 1
  For i% = 1 To Len(bytes$)
    b = Mid$(bytes$, i%, 1)
    Put #88, , b
  Next i%
End Sub

Function ser.read$ ()
  Dim b As String * 1: resp$ = ""
  Do While Loc(88)
    Get #88, , b: resp$ = resp$ + b
  Loop
  ser.read$ = resp$
End Function
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply


Messages In This Thread
Coms port and RAM disk - by Willi Grundmann - 03-05-2024, 03:01 AM
RE: Coms port and RAM disk - by mdijkens - 03-05-2024, 08:00 AM
RE: Coms port and RAM disk - by Pete - 03-05-2024, 08:13 AM
RE: Coms port and RAM disk - by RhoSigma - 03-05-2024, 09:10 AM



Users browsing this thread: 1 Guest(s)