B4R Question Stream write problems

newbie

Member
Licensed User
Longtime User
Hi,

i have problems to write a little bit more dat to a nextion-Display.
At first i mean there is a problem with the Display or my code, so i have spend a lot of time
to change and try something. -- No success

So i have write this little test code
B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'Public variables can be accessed from all modules.
   Public Serial1 As Serial

   Private Stream2 As AsyncStreams
  Private SerialNative2 As Stream
   
   Private timer1 As Timer
   Private x As Int = 1
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   
     ' Display
   RunNative("SerialNative2",Null)
   Stream2.Initialize(SerialNative2, "Stream2_newdata", Null)   
   
   timer1.Initialize("T1_action",100)
   timer1.Enabled = True
End Sub

Sub t1_action
   Log("Timer:",NumberFormat(x,0,0))
   x = x+1
   
   Stream2.Write("page 2").Write(Array As Byte(0xFF, 0xFF, 0xFF))
   Stream2.Write("stunde.txt=").Write(QUOTE).Write(NumberFormat(x,0,2)).Write(QUOTE).Write(Array As Byte(0xFF, 0xFF, 0xFF))
   Stream2.Write("t11.txt=").Write(QUOTE).Write(NumberFormat(x,0,2)).Write(QUOTE).Write(Array As Byte(0xFF, 0xFF, 0xFF))
   Stream2.Write("j0.val=").Write(NumberFormat(x,0,0)).Write(Array As Byte(0xFF, 0xFF, 0xFF))

End Sub

Sub stream2_NewData (Buffer() As Byte)

End Sub

this workes fine,
but when i duplicate the 4 lines (Stream2.write) in the timer event the application hangs

the same when:
- i make delays between the two blocks
- or make the timer.interval higher (10 sec)

it is not possible to transfer 8 lines
 
Top