Hallo
i have a compass that outputs uart data like that
$OHPR,21.2,2.3,-2.5,14.2,0.0000,370.48,-298.50,126.78,179.10,1.003,0.040,-0.043,1.002,-0.010C
$OHPR,21.2,2.3,-2.5,14.2,0.0000,370.47,-298.50,126.79,179.06,1.003,0.040,-0.043,1.002,-0.0105
and i wrote this programm to capture them
while ( Serial.read () != '
that works great
but when i copy the above to a bigger scetch
like that
void setup()
{
pinMode(3,OUTPUT);
digitalWrite(3,HIGH);
Serial.begin(UartBaudRate);
Wire.begin(I2C_Address);
Wire.onRequest(requestEvent);
Wire.onReceive(ReceiveCommand);
}
void loop()
{
if (command == 'H')
{
command = 'N';
Capture_OS4000();
}
else if (command == 'P')
{
digitalWrite(3,HIGH);
command = 'N';
}
else if (command == 'p')
{
digitalWrite(3,LOW);
command = 'N';
}
else if (command == 'R')
{
Serial.write(27);
delay(20);
Serial.print("R");
delay(20);
CommandLow = Wire.read();
CommandHigh = Wire.read();
Command = ( ( (int)CommandLow<<8 ) | ( (int)CommandHigh ) );
Serial.print(Command);
Serial.write(13);
command = 'N';
}
}
void Capture_OS4000()
{
while ( Serial.read () != '
then the output is like that
OHPR,21.2,2.3,-2.4,14.6,0.0000,371.$OHPR,21.3,2.3,-2.4,14.6,0.0000,370.59,-298.45,126.93,179.31,1.003,0.041,-0.042,1.002,-0.01.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,370.40,-298.41,126.96,178.9$OHPR,21.2,2.3,-2.5,14.6,0.0000,371.01,-298.50,127.11,179.97,1.003,0.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,371.$OHPR,21.2,2.3,-2.5,14.6,0.0000,370.70,-298.69,126.98,179.11,1.003,0.041,-0.045,1.001,-0.01.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,370.76,-298.72,126.99,179.1$OHPR,21.2,2.3,-2.5,14.6,0.0000,371.11,-298.72,127.07,179.84,1.003,0.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,371.$OHPR,21.2,2.3,-2.5,14.6,0.0000,370.66,-298.63,127.00,179.10,1.003,0.041,-0.043,1.001,-0.01.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,370.73,-298.65,127.01,179.2.4,14.6,0.0000,371.15,-298.74,127.02,179.92,1.003,0.041,-0.042,1.001,ÿ
where i am wrong
thanks a lot
);
BytesRead = Serial.readBytesUntil(’*’,SerialBuffer,127);
for(Position=(BytesRead+1); Position<128; Position++)
{
SerialBuffer[Position] = B0;
}
for(Position=0; Position<128; Position++)
{
OS4000Data[Position] = SerialBuffer[Position];
}
that works great
but when i copy the above to a bigger scetch
like that
§DISCOURSE_HOISTED_CODE_1§
then the output is like that
> OHPR,21.2,2.3,-2.4,14.6,0.0000,371.$OHPR,21.3,2.3,-2.4,14.6,0.0000,370.59,-298.45,126.93,179.31,1.003,0.041,-0.042,1.002,-0.01.ÿ
> OHPR,21.2,2.3,-2.5,14.6,0.0000,370.40,-298.41,126.96,178.9$OHPR,21.2,2.3,-2.5,14.6,0.0000,371.01,-298.50,127.11,179.97,1.003,0.ÿ
> OHPR,21.2,2.3,-2.5,14.6,0.0000,371.$OHPR,21.2,2.3,-2.5,14.6,0.0000,370.70,-298.69,126.98,179.11,1.003,0.041,-0.045,1.001,-0.01.ÿ
> OHPR,21.2,2.3,-2.5,14.6,0.0000,370.76,-298.72,126.99,179.1$OHPR,21.2,2.3,-2.5,14.6,0.0000,371.11,-298.72,127.07,179.84,1.003,0.ÿ
> OHPR,21.2,2.3,-2.5,14.6,0.0000,371.$OHPR,21.2,2.3,-2.5,14.6,0.0000,370.66,-298.63,127.00,179.10,1.003,0.041,-0.043,1.001,-0.01.ÿ
> OHPR,21.2,2.3,-2.5,14.6,0.0000,370.73,-298.65,127.01,179.2.4,14.6,0.0000,371.15,-298.74,127.02,179.92,1.003,0.041,-0.042,1.001,ÿ
where i am wrong
thanks a lot
);
BytesRead = Serial.readBytesUntil('*',SerialBuffer,127);
for(Position=(BytesRead+1); Position<128; Position++)
{
SerialBuffer[Position] = B0;
}
for(Position=0; Position<128; Position++)
{
OS4000Data[Position] = SerialBuffer[Position];
}
}
void ReceiveCommand(int howMany)
{
command = Wire.read();
}
void requestEvent()
{
Wire.write (OS4000Data, 127);
}
then the output is like that
OHPR,21.2,2.3,-2.4,14.6,0.0000,371.$OHPR,21.3,2.3,-2.4,14.6,0.0000,370.59,-298.45,126.93,179.31,1.003,0.041,-0.042,1.002,-0.01.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,370.40,-298.41,126.96,178.9$OHPR,21.2,2.3,-2.5,14.6,0.0000,371.01,-298.50,127.11,179.97,1.003,0.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,371.$OHPR,21.2,2.3,-2.5,14.6,0.0000,370.70,-298.69,126.98,179.11,1.003,0.041,-0.045,1.001,-0.01.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,370.76,-298.72,126.99,179.1$OHPR,21.2,2.3,-2.5,14.6,0.0000,371.11,-298.72,127.07,179.84,1.003,0.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,371.$OHPR,21.2,2.3,-2.5,14.6,0.0000,370.66,-298.63,127.00,179.10,1.003,0.041,-0.043,1.001,-0.01.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,370.73,-298.65,127.01,179.2.4,14.6,0.0000,371.15,-298.74,127.02,179.92,1.003,0.041,-0.042,1.001,ÿ
where i am wrong
thanks a lot
);
BytesRead = Serial.readBytesUntil(’*’,SerialBuffer,127);
for(Position=(BytesRead+1); Position<128; Position++)
{
SerialBuffer[Position] = B0;
}
for(Position=0; Position<128; Position++)
{
OS4000Data[Position] = SerialBuffer[Position];
}
that works great
but when i copy the above to a bigger scetch
like that
§DISCOURSE_HOISTED_CODE_1§
then the output is like that
> OHPR,21.2,2.3,-2.4,14.6,0.0000,371.$OHPR,21.3,2.3,-2.4,14.6,0.0000,370.59,-298.45,126.93,179.31,1.003,0.041,-0.042,1.002,-0.01.ÿ
> OHPR,21.2,2.3,-2.5,14.6,0.0000,370.40,-298.41,126.96,178.9$OHPR,21.2,2.3,-2.5,14.6,0.0000,371.01,-298.50,127.11,179.97,1.003,0.ÿ
> OHPR,21.2,2.3,-2.5,14.6,0.0000,371.$OHPR,21.2,2.3,-2.5,14.6,0.0000,370.70,-298.69,126.98,179.11,1.003,0.041,-0.045,1.001,-0.01.ÿ
> OHPR,21.2,2.3,-2.5,14.6,0.0000,370.76,-298.72,126.99,179.1$OHPR,21.2,2.3,-2.5,14.6,0.0000,371.11,-298.72,127.07,179.84,1.003,0.ÿ
> OHPR,21.2,2.3,-2.5,14.6,0.0000,371.$OHPR,21.2,2.3,-2.5,14.6,0.0000,370.66,-298.63,127.00,179.10,1.003,0.041,-0.043,1.001,-0.01.ÿ
> OHPR,21.2,2.3,-2.5,14.6,0.0000,370.73,-298.65,127.01,179.2.4,14.6,0.0000,371.15,-298.74,127.02,179.92,1.003,0.041,-0.042,1.001,ÿ
where i am wrong
thanks a lot