Trying to get familiar with the serial comm and streaming input data techniques. I have a feeling I am not understanding ReadSerialPortData(Com, *Buffer,availDat) . Some issue with the buffer and the "Length" parameter in the ReadSerialPortData command.
Receiving error:
ERROR: Overflow in a string memory block.
Code: Select all
Com = OpenSerialPort(#PB_Any, "COM11", 9600, #PB_SerialPort_NoParity, 8, 1, #PB_SerialPort_NoHandshake,1024, 1024)
If Not Com
MessageRequester("Error", "Can not open COM port!")
CloseSerialPort(Com)
End
EndIf
availDat.i = 0
Buffer.s = ""
*Buffer = @Buffer
If OpenWindow(0, 0, 0, 400, 100, "Serial Read Timer Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
AddWindowTimer(0, 1, 50)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Timer And EventTimer() = 1
If AvailableSerialPortInput(Com)
availDat = AvailableSerialPortInput(Com)
>>> error here ReadSerialPortData(Com, *Buffer,availDat)
Debug "*********Read Data************"
Debug PeekA(*Buffer)
Debug PeekA(*Buffer + 1)
Debug PeekA(*Buffer + 2)
Debug PeekA(*Buffer + 3)
Debug PeekA(*Buffer + 4)
Debug Buffer.s
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
10 7 59 0 190
I get six packets and the program crashes with the Error.