Data is still all garbled trash. I really dont understand why this is being so difficult. it works 100% with my gps. i am using the same standard for transferring data.
i have also noticed 'A' Buffers and 'B' Buffers appearing when only displaying ServoPos's data (not showing buffers at all)
these 2 pictures are of the p2p_buffer data at the beginning just after longfill & at the end before it repeats the loop. & 'B' Buffer using ser.tx.
then on prop1 i went and just told the servo parsing to listen on pSer instead of pWiFi:
' // Get Servo Data from PC
PRI rxData : v | i, ch ' Receive and parse servo data *** Runs in Own Cog
repeat
rCnt := 0
repeat until ser.rx(pSer) == "$"
rCnt++
repeat i from 0 to 8
v := 0
repeat
ch := ser.rx(pSer)
case ch
"0".."9": v := v*10 + ch-"0"
other: quit
ServoPos[i] := v
then i send the data out with dio.dec(ServoPos):
Pub Start | i
start_uarts ' Start Uart's (WiFi - 57600, P2P - 115200)
cog := cognew(rxData, @Data_stack) + 1 ' Run to prevent Lock-up during flight if link drops
waitcnt((clkfreq) + cnt) ' Start-up Delay
repeat
Ser.str(pDBG, string("Data IN: "))
repeat i from 0 to 8
dio.dec(pDBG, ServoPos[i])
Ser.str(pDBG, string(" "))
Ser.tx (pDBG, CR)
which displays the Correct Data on prop1 as you can see in picture below.
now, i can send numbers no problems, but alphas??? not sure how to do them too. need to be able to do " N S E W A V - . " and floating point numbers... or will i have to make a code for each of these?
What I am currently trying to get to work (any way i can) with alpha-numeric data:
' Data OUT (Prop2):
' ser.str(pSer, string("$1000|1500|2000|9999|1234|4321|6666|1|1000|1500|2000|9999|1234|4321|777|1111|-2.2G2|44.44|5zY5|5A2b|999|"))
notice -2,2G2 is missing the "-,G", 5zY5 is missing zY, and 5A2b is missing Ab.
Numbers 100% return.
Also, i can only use so hgh of a number before it becomes something it is not. way off scale.
Pub Start | i
start_uarts ' Start Uart's (WiFi - 57600, P2P - 115200)
cog := cognew(rxData, @Data_stack) + 1 ' Run to prevent Lock-up during flight if link drops
waitcnt((clkfreq) + cnt) ' Start-up Delay
repeat
Ser.str(pDBG, string("Data IN: "))
repeat i from 0 to 20
dio.dec(pDBG, ServoPos[i])
Ser.str(pDBG, string(" "))
Ser.tx (pDBG, CR)
' Data OUT (Prop2):
' ser.str(pSer, string("$1000|1500|2000|9999|1234|4321|6666|1|1000|1500|2000|9999|1234|4321|777|1111|-2.2G2|44.44|5zY5|5A2b|999|"))
' Data IN (Prop1): 1000 1500 2000 9999 1234 4321 6666 1 1000 1500 2000 9999 1234 4321 777 1111 222 4444 55 52 999
' // Get Servo Data from PC
PRI rxData : v | i, ch ' Receive and parse servo data *** Runs in Own Cog
repeat
rCnt := 0
repeat until ser.rx(pSer) == "$"
rCnt++
repeat i from 0 to 20
v := 0
repeat
ch := ser.rx(pSer)
case ch
"0".."9": v := v*10 + ch-"0"
"|": quit
bytemove(@ServoPos[i], @v, strsize(@v)) ' Trying to display as a string, no luck. (both this & ServoPos[i] := v works fine)
'ServoPos[i] := v
Pub rxP2P | i
repeat
'ser.str(pDBG, string("Start"))
'ser.tx(pDBG, 13)
'bytefill(p2p_buff,0,20)
'longfill(p2p_buff,20,0)
'ser.str(pDBG, string("Begin Repeat"))
'ser.tx(pDBG, 13)
repeat while Rx <>= "$" ' wait for the $ to insure we are starting with
'repeat while Rx <> "$" ' wait for the $ to insure we are starting with
Rx := ser.rx(pSer) ' a complete NMEA sentence
cptr := 0
repeat while Rx <>= CR ' continue to collect data until the end of the NMEA sentence
Rx := ser.rx(pSer) ' get character from Rx Buffer
if Rx == ","
p2p_buff[cptr++] := 0 ' If "," replace the character with 0
else
p2p_buff[cptr++] := Rx ' else save the character
dio.dec(pDBG, cptr - 1)
ser.str(pDBG, string(": "))
ser.tx(pDBG, Rx)
ser.str(pDBG, string(" "))
ser.tx(pDBG, p2p_buff[cptr - 1])
ser.tx(pDBG, 13)
if p2p_buff[0] == "G"
if p2p_buff[1] == "P"
if p2p_buff[2] == "S"
copy_buffer(@GPSb, @GPSa)
if p2p_buff[0] == "W"
if p2p_buff[1] == "A"
if p2p_buff[2] == "P"
copy_buffer(@WAPb, @WAPa)
if p2p_buff[0] == "L"
if p2p_buff[1] == "C"
if p2p_buff[2] == "F"
copy_buffer(@LCFb, @LCFa)
if p2p_buff[0] == "A"
if p2p_buff[1] == "I"
if p2p_buff[2] == "R"
copy_buffer(@AIRb, @AIRa)
Here is what Rx & p2p_buff is showing at last... but still no data out from ***a (copy_buffer)
So it now reads longfill(p2p_buff, 0, 20)? What's the value of the start address for this function?
Ok, so i did some more testing...
Pub rxP2P | i
repeat
'bytefill(p2p_buff,0,20)
'longfill(p2p_buff,20,0)
repeat while Rx <>= "$" ' wait for the $ to insure we are starting with
Rx := ser.rx(pSer) ' a complete NMEA sentence
cptr := 0
repeat while Rx <>= CR ' continue to collect data until the end of the NMEA sentence
Rx := ser.rx(pSer) ' get character from Rx Buffer
if Rx == ","
p2p_buff[cptr++] := 0 ' If "," replace the character with 0
else
p2p_buff[cptr++] := Rx ' else save the character
dio.dec(pDBG, cptr - 1)
ser.str(pDBG, string(": "))
ser.tx(pDBG, Rx)
ser.str(pDBG, string(" "))
ser.tx(pDBG, p2p_buff[cptr - 1])
ser.tx(pDBG, 13)
if p2p_buff[0] == "G"
if p2p_buff[1] == "P"
if p2p_buff[2] == "S"
copy_buffer(@GPSb, @GPSa)
ser.str(pDBG, string("Yes"))
ser.tx(pDBG, 13)
if p2p_buff[0] == "W"
if p2p_buff[1] == "A"
if p2p_buff[2] == "P"
copy_buffer(@WAPb, @WAPa)
ser.str(pDBG, string("Yes"))
ser.tx(pDBG, 13)
if p2p_buff[0] == "L"
if p2p_buff[1] == "C"
if p2p_buff[2] == "F"
copy_buffer(@LCFb, @LCFa)
ser.str(pDBG, string("Yes"))
ser.tx(pDBG, 13)
if p2p_buff[0] == "A"
if p2p_buff[1] == "I"
if p2p_buff[2] == "R"
copy_buffer(@AIRb, @AIRa)
ser.str(pDBG, string("Yes"))
ser.tx(pDBG, 13)
And the results are shown in the picture below, all 4 "Yes"'s are being displayed & the data in p2p_buff is displayed correct as well.
But, there is still no correct values comming out of any copy_buffer(@GPSb, @GPSa).
At this point, the problem must be in copy_buffer and not rxP2P.
This is a cut down version just processing GPS messages. Incoming string can be up to 200 characters in size and hold 20 elements. When the buffer is diplayed I simply scan the A buffer and print its address and - if not empty - the sub string derived from the incoming message.
For further processing those strings have to be converted to whatever internal representation is required, e.g. latitude should be passed to StringToFloat etc.
This is a cut down version just processing GPS messages. Incoming string can be up to 200 characters in size and hold 20 elements. When the buffer is diplayed I simply scan the A buffer and print its address and - if not empty - the sub string derived from the incoming message.
For further processing those strings have to be converted to whatever internal representation is required, e.g. latitude should be passed to StringToFloat etc.
with a strange stroke of luck, I have gotten the GPS version to work!!!
Var
' ================ Cog & Stack ================
long cog1, cog2, cog3
long P2P_Stack[200], WiFi_Stack[100], Servo_Stack[100]
' ================ P2P Buffers ================
byte p2p_buff[200], Rx
byte GPSb[100], WAPb[40], LCFb[40], AIRb[40]
long GPSa[20], WAPa[20], LCFa[20], AIRa[20]
long Null[1], cptr, arg, ptr, j
Pub rxP2P
Null[0] := 0
repeat
repeat while Rx <>= "$" ' wait for the $ to insure we are starting with
Rx := ser.rx(pSer) ' a complete NMEA sentence
cptr := 0
repeat while Rx <>= CR ' continue to collect data until the end of the NMEA sentence
Rx := ser.rx(pSer) ' get character from Rx Buffer
if Rx == ","
p2p_buff[cptr++] := 0 ' If "," replace the character with 0
else
p2p_buff[cptr++] := Rx ' else save the character
if p2p_buff[0] == "G"
if p2p_buff[1] == "P"
if p2p_buff[2] == "S"
copy_buffer(@GPSb, @GPSa)
if p2p_buff[0] == "W"
if p2p_buff[1] == "A"
if p2p_buff[2] == "P"
copy_buffer(@WAPb, @WAPa)
if p2p_buff[0] == "L"
if p2p_buff[1] == "C"
if p2p_buff[2] == "F"
copy_buffer(@LCFb, @LCFa)
if p2p_buff[0] == "A"
if p2p_buff[1] == "I"
if p2p_buff[2] == "R"
copy_buffer(@AIRb, @AIRa)
' // Update Values
UpdateProp2Data
SendDataTerm
Pri copy_buffer (buffer,args)
bytemove(buffer,@p2p_buff,cptr) ' copy received data to buffer
ptr := buffer
arg := 0
repeat j from 0 to cptr - 1 ' build array of pointers
if byte[ptr] == 0 ' to each
if byte[ptr+1] == 0 ' record
long[args][arg] := Null ' in
else ' the
long[args][arg] := ptr+1 ' data buffer
arg++
ptr++
Pri UpdateProp2Data
' // BMP180
BMP180_Temperature := AIRa[0]
BMP180_Pressure := AIRa[1]
' // $LCF
lfLat := fs.StringToFloat(LCFa[0]) ' Float
lfLon := fs.StringToFloat(LCFa[1]) ' Float
lfAlt := fs.StringToFloat(LCFa[2]) ' Float
gpsLat := fs.StringToFloat(LCFa[3]) ' Float
gpsLon := fs.StringToFloat(LCFa[4]) ' Float
gpsAlt := fs.StringToFloat(LCFa[5]) ' Float
' // $WAP
wCurCnt := fs.StringToFloat(WAPa[0]) ' Float
wDist := fs.StringToFloat(WAPa[1]) ' Float
wDistance := fs.StringToFloat(WAPa[2]) ' Float
wMidLat := fs.StringToFloat(WAPa[3]) ' Float
wMidLon := fs.StringToFloat(WAPa[4]) ' Float
wBearing := fs.StringToFloat(WAPa[5]) ' Float
cWAPLat := fs.StringToFloat(WAPa[6]) ' Float
cWAPLon := fs.StringToFloat(WAPa[7]) ' Float
isWAP := fs.StringToFloat(WAPa[8]) ' Float
tRate := WAPa[9]
HomeValid := WAPa[10]
' // $GPS
Valid := GPSa[0]
Date := GPSa[1]
Altitude := fs.StringToFloat(GPSa[2]) ' Float
Speed := fs.StringToFloat(GPSa[3]) ' Float
Heading := fs.StringToFloat(GPSa[4]) ' Float
Time := GPSa[5]
Latitude := fs.StringToFloat(GPSa[6]) ' Float
N_S := GPSa[7]
Longitude := fs.StringToFloat(GPSa[8]) ' Float
E_W := GPSa[9]
Satellites := GPSa[10]
hdop := GPSa[11]
Heading2 := fs.StringToFloat(GPSa[12]) ' Float
SpeedKn := fs.StringToFloat(GPSa[13]) ' Float
SpeedKm := GPSa[14]
Lat2 := fs.StringToFloat(GPSa[15]) ' Float
N_S2 := GPSa[16]
Lon2 := fs.StringToFloat(GPSa[17]) ' Float
E_W2 := GPSa[18]
GPS_Alt := GPSa[19]
Comments
i have also noticed 'A' Buffers and 'B' Buffers appearing when only displaying ServoPos's data (not showing buffers at all)
these 2 pictures are of the p2p_buffer data at the beginning just after longfill & at the end before it repeats the loop. & 'B' Buffer using ser.tx.
then on prop1 i went and just told the servo parsing to listen on pSer instead of pWiFi:
then i send the data out with dio.dec(ServoPos):
which displays the Correct Data on prop1 as you can see in picture below.
now, i can send numbers no problems, but alphas??? not sure how to do them too. need to be able to do " N S E W A V - . " and floating point numbers... or will i have to make a code for each of these?
' Data OUT (Prop2):
' ser.str(pSer, string("$1000|1500|2000|9999|1234|4321|6666|1|1000|1500|2000|9999|1234|4321|777|1111|-2.2G2|44.44|5zY5|5A2b|999|"))
' Data IN (Prop1): 1000 1500 2000 9999 1234 4321 6666 1 1000 1500 2000 9999 1234 4321 777 1111 222 4444 55 52 999
notice -2,2G2 is missing the "-,G", 5zY5 is missing zY, and 5A2b is missing Ab.
Numbers 100% return.
Also, i can only use so hgh of a number before it becomes something it is not. way off scale.
Here is what Rx & p2p_buff is showing at last... but still no data out from ***a (copy_buffer)
Ok, so i did some more testing...
And the results are shown in the picture below, all 4 "Yes"'s are being displayed & the data in p2p_buff is displayed correct as well.
But, there is still no correct values comming out of any copy_buffer(@GPSb, @GPSa).
At this point, the problem must be in copy_buffer and not rxP2P.
looks pretty much right, compare to:
my result is:
$GPS,A,120114,1528,0.63,347.19,003936.400,40.56688,N,-105.065,W,7,1.09,346.85,0.63,1.17,40.56688,N,-105.065,W
For further processing those strings have to be converted to whatever internal representation is required, e.g. latitude should be passed to StringToFloat etc.
with a strange stroke of luck, I have gotten the GPS version to work!!!