Hi Alex, have a look at this code for some ideas how I have serial comms 
working.
' Gambas class file

Private Sport As SerialPort
Public Pp As Byte
Public Po As Byte
Public Rxs As String

Public Sub Form_Open()
  Me.Load
  Me.Center
End

Public Sub Button2_Click()
  Sport = New SerialPort As "Sport"
  Po = 1
  
  If TextBox3.Text = "N" Or TextBox3.Text = "n" Then
    pp = 0
  End If
  
  With Sport
    .PortName = TextBox1.Text
    .Speed = TextBox2.Text
    .Parity = Pp
    .DataBits = TextBox4.Text
    .StopBits = TextBox5.Text
    .FlowControl = Val(TextBox6.text)
  Try
    .Open()
    Label9.Text = TextBox1.Text & ":" & TextBox2.Text & "," & TextBox3.Text & 
"," & TextBox4.Text & "," & TextBox5.Text & "  OPEN"
    Label10.Background = &H00FF00&  
    If Error Then
      Message(" Port " & TextBox1.Text & " not found -- TERMINATING PROGRAM")
      Quit
    Endif
  End With

End

Public Sub Sport_Read()
  Dim Rx As String
  Read #Sport, Rx, Lof(Sport)
  Rxs = Rxs & Rx
  If Rx = Chr$(13) Then
    TextArea1.Text = TextArea1.Text & Rxs
    Rxs = ""
  End If
End

Public Sub Button1_Click()
  If Po = 0 Then
    Message("Open the PORT")
  Else
    Print #Sport, Textbox7.Text; Chr$(13)
  End If
End

Public Sub Button3_Click()
  Sport.Close
  Label10.Background = &HFF0000&
  Label9.Text = "CLOSED"
  Po = 0
End

Public Sub Button4_Click()
  TextArea1.Clear
End

Public Sub Button5_Click()
  EndIt()  
End

Public Sub Form_Close()
  EndIt()
End

Public Sub EndIt()
  Try
    Sport.Close
    Quit
  If Error Then
    Quit  
  Endif
End


RegardsMike
 

    On Tuesday, 9 May 2017, 0:12, alexchernoff <alexchern...@hotmail.com> wrote:
 

 Dear all,

I am receiving data over a serial port which is sent by a byte[].write
function (an array of bytes)

I get the SerialPort1_read() event raised where I try to read data, RxBuffer
is a string var

*Try Read #SerialPort1, RxBuffer, Lof(SerialPort1)*

as soon as I do, the whole program stops, some other timers in other modules
also stop to fire. In fact when running the program in Gambas again, it does
not execute even the startup, so have to restart the IDE. 

what am I doing wrong?

thanks!




--
View this message in context: 
http://gambas.8142.n7.nabble.com/Serial-I-O-with-byte-data-tp58933.html
Sent from the gambas-user mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


   
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to