Android Question Serial BT connection problem...

Spectre

Active Member
Licensed User
Hi!
I have this problem with the serial connection BT . The system connects But when I try to read the serial dates From BT freezes code ...



B4X:
Sub Timer_buffer_Tick   
'when the connection is established check the serial Arduino to receive the time from sensors

    If connected Then      

                '******************EXTRACT STRAT E STOP TIME********
                Dim StartTime As Float
                Dim StopTime As Float              
                Dim RX_string As String
               
                RX_string=text_serial_in.ReadLine    & CRLF
                lbl_sens1.Text=sf.MidExtract(RX_string,"(",")")
                lbl_sens2.Text=sf.MidExtract(RX_string,"[","]")
                StartTime=sf.MidExtract(RX_string,"(",")")                   
                StopTime=sf.MidExtract(RX_string,"[","]")           
                '***************************************************
                StringRead=Calc_speed(StopTime-StartTime)
                Calcoli(StringRead)                   
                ToastMessageShow("**** PRONTO/READY ****",False)
            Catch
                Msgbox("Colpo non rivelato/ Bad Shot","Avviso/Alert")
                Return           
            End Try
           
        If  IsNumber(StringRead)=False Then
                Return
            End If           
        End If
    End If
    If chk_showstat.Checked=True Then
        If ShotCount > =  spi_NShot.SelectedItem + 1 Then   
            If Timerit > 4 Then
'            per uso futuro
       
            End If
        End If
    End If
End Sub
 

Erel

Administrator
Staff member
Licensed User
The only proper way to read data from a Bluetooth device (or socket) is with AsyncStreams.
 
Top