Luke
Newbie

Posts: 3
|
 |
« on: December 13, 2017, 06:26:41 pm » |
|
I am getting "bad record length" error at the GET #1, ,m$ statement in the following QB64 code. I can't seem to find exactly how I should go about reading the message posted in the com port buffer by Arduino when all I asked for is A/D voltage on analog pin 4. Any Ideas? OPEN "Com3:9600,n,8,1,ds0,cs0,rs" FOR RANDOM AS #1 _DELAY .5 ' Delay to let Com Port settle FIELD #1, 50 AS m$
t1 = TIMER ' Start time for getdata
getdata: bytes% = LOC(1) ' Check receive buffer for data IF bytes% = 0 THEN GOTO getdata ' After thousands of getdata cycles it continues PRINT "Bytes="; bytes ' Bytes remain at 0 DO UNTIL EOF(1) GET #1, , m$ ' BAD RECORD LENGTH ERROR PRINT "LEN(m$)= "; LEN(m$) ' Length of m$ = 10 IF INSTR(m$, "*") > 0 THEN GOTO duh ' Never finds End of Message (*) LOOP
IF bytes% = 0 THEN GOTO getdata t2 = TIMER ' End time, Have data DeltaT = t2 - t1 ' How long did it take? GOTO stepover
duh: PRINT "DUH instr= "; INSTR(m$, "*") ' Never hits this line stepover:
tmp$ = "DeltaT= #.### Seconds Until LOC(1) > 0" ' Various times arround 0.66 Sec PRINT USING tmp$; DeltaT PRINT "m$ Received= "; m$ + "&" ' Prints 10 spaces No Data PRINT "endofdata= "; endofdata ' endofdata=0, Never got "*" PRINT "ctr= "; ctr, CHR$(13) ' Show number of times you pressed continue CLOSE #1
Arduino Code sending info is the following:
if ( cmd == 2)//getanalog { int sensorValue = analogRead(pin);// delay(10); float voltage= sensorValue*(5.0/1023.0); Serial.print("Voltage ="); Serial.print(voltage); Serial.print(","); Serial.print("*");
The asterisk should be in the buffer indicating the end of my message.
|
|
|
|
|
|
|