Asych from micro to XOOM...data type

Graham

Member
Licensed User
Longtime User
I can talk from XOOM to microchip but from microchip to XOOM isn't working. I'm pretty sure I am sending back to the XOOM because when I start to transmit to the XOOM, the B4A app locks up.

I have tried all data types with no luck, so I bet there is something else wrong in my transmitting from microchip to the XOOM but it would be nice to eliminate one variable (data type).

Below is the microchip code in PicBasic.

Thanks for your help


B4X:
Send_BT:
  Prefix1=0
  Prefix2=0
  Prefix3=0
  Prefix4=4
  RPM1T=34
  RPM2T=65
  RPM3T=232
  RPM4T=45
  debug hex Prefix1,hex Prefix2,hex Prefix3,hex Prefix4,hex RPM1T,hex RPM2T,hex RPM3T,hex RPM4T
Return
 

Graham

Member
Licensed User
Longtime User
B4X:
#Region Module Attributes
   #FullScreen: False
   #IncludeTitle: True
#End Region

'Activity module
Sub Process_Globals
   Dim AStream As AsyncStreams
   Dim Timer1 As Timer
End Sub

Sub Globals
   Dim txtInput As EditText
   Dim txtLog As EditText
   Dim btnSend As Button
   Dim Var1,Var2,Var3,Var4,Var5,Var6,Var7,Var8,Var9,Var10,Var11,Var12,Var13,Var14,Var15,Var16,Var17,Var18,Var19,Var20,Var21,Var22,Var23,Var24 As Short
   Dim Var25,Var26,Var27,Var28,Var29,Var30,Var31,Var32,Var33,Var34,Var35,Var36,Var37,Var38,Var39,Var40,Var41,Var42,Var43,Var44,Var45,Var46,Var47,Var48 As Short
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("2")
   If AStream.IsInitialized = False Then
      AStream.InitializePrefix(Main.serial1.InputStream, True, Main.serial1.OutputStream, "AStream")
   End If
   txtLog.Width = 100%x
Timer1.Initialize("Timer1", 100) ' 1000 = 1 second
   Timer1.Enabled = True
End Sub

Sub AStream_NewData (Buffer() As Byte)
   LogMessage("You", BytesToString(Buffer, 0, Buffer.Length, "ISO8859_1"))
End Sub

Sub AStream_Error
   ToastMessageShow("Connection is broken.", True)
   btnSend.Enabled = False
   txtInput.Enabled = False
End Sub

Sub AStream_Terminated
   AStream_Error
End Sub

Sub Timer1_Tick '(Buffer() As Byte)
Var1=800 
Var2=200
Var3=200
Var4=500
Var5=5
Var6=6
Var7=7
Var8=8
Var9=9
Var10=10
Var11=11
Var12=12
Var13=13
Var14=14
Var15=15
Var16=16
Var17=17
Var18=18
Var19=19
Var20=20
Var21=21
Var22=22
Var23=23
Var24=24
'This code sends to microchip ok
      txtInput.TExt="R," & Var1 & "," & Var2 &"," & Var3 & "," & Var4 & "," & Var5 & "," & Var6 & "," & Var7 & "," & Var8 & "," & Var9 & "," & Var10 & "," & Var11 & "," & Var12 _
                   & "," & Var13 & "," & Var14 & "," & Var15 & "," & Var16 & "," & Var17 & "," & Var18 & "," & Var19 & "," & Var20 & "," & Var21 & "," & Var22 & "," & Var23 & "," & Var24
               
   
   AStream.Write(txtInput.TExt.GetBytes("ISO8859_1"))
   txtInput.SelectAll
   txtInput.RequestFocus
   LogMessage("Me", txtInput.TExt) 
End Sub

Sub Activity_Resume
   
End Sub

Sub Activity_Pause (UserClosed As Boolean)
   If UserClosed Then
      AStream.Close
   End If
End Sub



Sub LogMessage(From As String, Msg As String)
   txtLog.TExt = txtLog.TExt & From & ": " & Msg & CRLF
   txtLog.SelectionStart = txtLog.TExt.Length
End Sub
 
Upvote 0

Graham

Member
Licensed User
Longtime User
Reference the first code I posted,it first sends the prefix. I am writing the code for the microchip and the Xoom. I just need to know what data type B4A is expecting for the prefix and I think I can get a handle on this.

PHP:
  Prefix1=0
  Prefix2=0
  Prefix3=0
  Prefix4=4
  RPM1T=34
  RPM2T=65
  RPM3T=232
  RPM4T=45
' Debug is the command that sends out a serial stream, it is configured for 9600 bps 8N1
  debug hex Prefix1,hex Prefix2,hex Prefix3,hex Prefix4,hex RPM1T,hex RPM2T,hex RPM3T,hex RPM4T
 
Last edited:
Upvote 0
Top