Hello
I'm communicating by usb hub with TinyG
I use serial library.
I should get data line by line in json so i want to parse some data (positions etc) into variable from data which i get in json.
I use this :
Where : EditTextgcodevystup - edittext with output data
prijate - string containing data which i get
iks - variabla containing position x (get from parsing ,,prijate,, data)
label1 - if graphical part of aplication which is showing and x position like for example (X = 27)
Like i write i should get data line by line (everytime prijate should contain one line of data in json format)
To i see what data i get (in how part i get it) i adding an start (*) after each part of data which i get so the
output should be like :
But my output see like :
Where isn't the star still in the end of line where should be if i get data line be line -> that means data doesn't coming to me every time line by line
But if i wan't to parse that data it must come to parse line by line in json to valid parse.
So what i should to to separate that coming data line by line and send to parse (parser.initialize(prijate)) only full line with json (only one line) that meand data from one clrf to other clrf(new line) like ( CLRF somedata which i want to parse CLRF)
Thank's for help.
Have a nice day
I'm communicating by usb hub with TinyG
I use serial library.
I should get data line by line in json so i want to parse some data (positions etc) into variable from data which i get in json.
I use this :
B4X:
Sub Astreams_NewData (Buffer() As Byte)
If EditTextgcodevystup.Text.Length > 10000 Then EditTextgcodevystup.Text = ""
'it will delete output text when length of data is more than 10000
Dim prijate = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
Log(prijate)
'spracuje
Dim parser As JSONParser
parser.Initialize(prijate)
Dim root As Map = parser.NextObject
Dim sr As Map = root.Get("sr")
Dim vel As Double = sr.Get("vel")
Dim posx As Double = sr.Get("posx")
label1.Text = " X = "&posx
'set text with position of x
iks = posx
'set variable which contains position of x
EditTextgcodevystup.Text = EditTextgcodevystup.Text & prijate & "*"
'put data which i get into my output edittext
EditTextgcodevystup.SelectionStart = EditTextgcodevystup.Text.Length
End Sub
Where : EditTextgcodevystup - edittext with output data
prijate - string containing data which i get
iks - variabla containing position x (get from parsing ,,prijate,, data)
label1 - if graphical part of aplication which is showing and x position like for example (X = 27)
Like i write i should get data line by line (everytime prijate should contain one line of data in json format)
To i see what data i get (in how part i get it) i adding an start (*) after each part of data which i get so the
output should be like :
B4X:
...somedata...*
...other data...*
...blablabla...*
...other....*
...something...*
But my output see like :
B4X:
...somedata...*
...other data...*
...blablabla...*
...other...*...
...so*mething...
...otherthing*...
...blablabla...*
Where isn't the star still in the end of line where should be if i get data line be line -> that means data doesn't coming to me every time line by line
But if i wan't to parse that data it must come to parse line by line in json to valid parse.
So what i should to to separate that coming data line by line and send to parse (parser.initialize(prijate)) only full line with json (only one line) that meand data from one clrf to other clrf(new line) like ( CLRF somedata which i want to parse CLRF)
Thank's for help.
Have a nice day