Okay, thank you very much for the pointers. I made some changes to my code (including a record-enable function so that I can stop the recording and keep the file intact). I also implemented newsoftserial as suggested.
Here is what I now have.
/*
Serial to SD card DATA logger
*/
#include <ctype.h>
#include <NewSoftSerial.h>
NewSoftSerial mySerial(6, 7); //pin 6 RX from device pin 7 TX to device
byte writing = 2; //LED writing indicator
byte recordenable = 5; //record enable pin
#include "FileLogger.h"
// variable used when reading from serial
byte inSerByte = 0;
void setup() {
Serial.begin(115200);
pinMode(recordenable, INPUT);
pinMode(writing, OUTPUT);
Serial.println("Online!");
// set the data rate for the NewSoftSerial port
mySerial.begin(9600);
mySerial.println("Begin");
}
void loop()
{
byte val = 0;
while(digitalRead(recordenable) == HIGH) { //check for record enable signal
digitalWrite(writing,HIGH); //indicate that recording is active
if (mySerial.available()) {
val = (char)mySerial.read(),BYTE;
int long length = sizeof(val) - 1;
//FileLogger::append("GPS.txt", &val, 1);
Serial.print(val);
}
}
while(digitalRead(recordenable) == LOW) { //check for record enable signal
digitalWrite(writing,LOW); //indicate that recording is inactive
}
}
Right now, when I monitor my PC PC serial port in Arduino this is what I see ...
Online!
[]]õ?ù;û7û÷vn}ù???ùû÷öv,ö6ìöövì?´öövì6ìöövì6ìööæÙvV6ìöövlÖ6ìööùWW}§?§?£??§{??ss§?£???§??£???§?£???§?£???§?£???§???£???§??£???§?£???§?«?{åë«ïݽýÿÿÿOÿÿÿ
ûÿÿÿÿÿÿ?|É}A/ÿ??2}#?}Î,?ü$Ù*7?rþ?|Ý1 àýûÿÿÇÇߢéñÿ?Õ·"?õßÇ?rÿÿÿÿ«ïÝñ?ÿÿÿGûÿÿ
ýÿÿÿÿÿÿG?É}ÿÿÿÿéÿÿÿïÿÿÿ÷?ÿÿÿï[Y§aÒþüÿÿ?Ãÿs9Yá«Ä?©ZGá÷*òüU(½iö?1}ÿÿÿÿñÿÿÿÓ?ÿÿÿsÆB?¯þþÿÿÏùJ§ÊN??ãÿÿÿÿÿÿÿÿ÷/bÂõ?]é?ÿÿÿåÿÿÿ·?ÿÿÿY??ONþüÿÿ¯¶êy«'3Â,èXv7B×öçå¹jV|t?êýÿÿÿÙÿÿÿ??ÿÿÿéîÚÜþþÿÿ7éfâý½è
¬éëÞô,½£1õÿÇÕ?&[Ñ}ÿÿÿÿÍÿÿÿw?ÿÿÿ©?wvþþÿÿ/M?þþ}?ê©?¯bBHGÁíTÎ?ÜõÙS&ò*ôýÿÿÿÝÿÿÿW?ÿÿþ*Ä?\ôXùýÿÿ5éúþÝ}?¹kTæÿÿÿÿ_ÏiyKÉ}ÿÿÿÿéÿÿÿ7?ÿÿÿõ¢^©?þþÿÿÇO?ù £:??R¤YQs>¯ÿÿ? 2?»Ã'}ÿÿÿÿÂÿÿÿ?ÿÿÿ?ç®"î«ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿíÿÿÿÇÿÿÿ÷ÿÿÿã+ *>öþüÿÿ/imé?W)?[?ëQs>ÿ·þdL;¨?}ÿÿÿÿëÿÿÿ×ÿÿÿ?»¿Ç©?þþÿÿg-!ÏGö"Tî??????zɽÛ+C?}ÿÿÿÿÿÿÿ½¿ýÿþñ?RÔþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿÿÿÿÿÿÿÿÿÿíÿÿÿ
When using HyperTerminal and viewing rhe output of the GPS device, this is what I see...
$PVAA,505,438277.05,-2546918.663,-4611650.436,3583500.395,0.065,0.037,0.194,0.151,0.067,0.332,1,1,1*03
$PVAA,505,438277.15,-2546918.628,-4611650.414,3583500.421,0.021,-0.086,0.000,0.054,-0.546,0.380,1,1,1*08
$PVAA,505,438277.20,-2546918.624,-4611650.407,3583500.406,-0.068,0.027,0.048,-0.152,0.451,0.478,1,1,1*0F
$PVAA,505,438277.30,-2546918.606,-4611650.358,3583500.383,0.043,0.029,0.031,0.119,0.208,0.144,1,1,1*0F
$PVAA,505,438277.35,-2546918.616,-4611650.359,3583500.362,-0.146,-0.141,-0.069,0.163,0.251,-0.766,1,1,1*04
$PVAA,505,438277.45,-2546918.608,-4611650.358,3583500.290,0.123,0.187,-0.062,0.381,0.458,0.097,1,1,1*26
$PVAA,505,438277.50,-2546918.624,-4611650.417,3583500.312,0.023,0.073,-0.069,-0.961,-0.807,-0.055,1,1,1*0A
$PVAA,505,438277.60,-2546918.523,-4611650.321,3583500.279,-0.097,-0.076,-0.023,-0.851,-0.658,-0.170,1,1,1*07
$PVAA,505,438277.65,-2546918.520,-4611650.313,3583500.280,0.091,0.145,0.059,0.222,0.384,0.208,1,1,1*0A
$PVAA,505,438277.75,-2546918.552,-4611650.322,3583500.244,0.026,-0.024,-0.011,0.204,-0.048,0.131,1,1,1*21
$PVAA,505,438277.80,-2546918.554,-4611650.337,3583500.341,-0.062,-0.071,0.069,-0.103,0.438,-0.117,1,1,1*0C
$PVAA,505,438277.85,-2546918.560,-4611650.340,3583500.342,-0.052,0.003,-0.042,0.101,0.326,0.101,1,1,1*0F
$PVAA,505,438277.95,-2546918.706,-4611650.493,3583500.333,-0.118,-0.079,-0.063,-1.060,-0.733,-0.588,1,1,1*00
$ATTA,0,0.00,B00FF,0.000,30.000,0.000,0.000,0.000,245.000,61.000,0.000,0*5B
$PVAA,505,438278.20,-2546918.756,-4611650.742,3583500.662,-0.044,-0.092,0.081,-0.392,-0.566,0.443,1,1,1*00
$PVAA,505,438278.30,-2546918.763,-4611650.708,3583500.635,0.007,0.029,0.031,-0.164,0.318,0.395,1,1,1*22
$PVAA,505,438278.40,-2546918.586,-4611650.484,3583500.595,0.070,0.087,-0.062,0.361,0.320,-0.418,1,1,1*03
$PVAA,505,438278.50,-2546918.572,-4611650.477,3583500.596,0.046,0.179,-0.136,0.040,0.802,-0.750,1,1,1*07
$PVAA,505,438278.60,-2546918.463,-4611650.357,3583500.495,-0.002,0.026,0.011,0.063,0.762,-0.339,1,1,1*0E
$PVAA,505,438278.75,-2546918.684,-4611650.524,3583500.434,0.020,0.072,-0.074,0.332,0.577,-0.466,1,1,1*06
$PVAA,505,438278.85,-2546918.671,-4611650.551,3583500.388,-0.095,-0.051,-0.012,-0.271,-0.326,0.330,1,1,1*23
$PVAA,505,438278.95,-2546918.606,-4611650.462,3583500.368,0.047,0.041,-0.023,0.324,0.420,-0.244,1,1,1*0E
$PVAA,505,438279.10,-2546918.482,-4611650.261,3583500.311,0.011,0.047,-0.046,-0.033,0.392,-0.405,1,1,1*24
$PVAA,505,438279.25,-2546918.399,-4611650.179,3583500.515,-0.052,-0.102,-0.055,-0.777,-0.763,0.137,1,1,1*2B
$PVAA,505,438279.35,-2546918.379,-4611650.180,3583500.509,0.050,0.054,0.091,-0.146,-0.429,0.918,1,1,1*06
$PVAA,505,438279.55,-2546918.430,-4611650.208,3583500.573,0.009,0.021,-0.025,0.158,-0.074,-0.158,1,1,1*27
$PVAA,505,438279.60,-2546918.422,-4611650.292,3583500.692,0.011,-0.067,0.085,0.018,-0.563,0.862,1,1,1*07
$PVAA,505,438279.70,-2546918.434,-4611650.321,3583500.704,-0.044,-0.090,0.087,-0.019,-0.234,0.400,1,1,1*00
$PVAA,505,438279.85,-2546918.519,-4611650.491,3583500.813,-0.001,-0.094,0.044,-0.677,-1.522,0.454,1,1,1*05
$PVAA,505,438279.95,-2546918.491,-4611650.466,3583500.811,-0.022,-0.000,-0.117,0.349,0.712,-0.652,1,1,1*08
$SPHA,505,438280.05,0.078,248.150,0.045,0*0E
Any suggestion why the data received in Arduino appears to be garbage?
I tried using..
val = (char)mySerial.read();
val = (char)mySerial.read(),BYTE;
val = (char)mySerial.read(),DEC;
val = (char)mySerial.read(),BIN;
val = (char)mySerial.read(),OCT;
val = (char)mySerial.read(),HEX;
Once I can get the data under control in the serial interface, I will work on the actual recording. (I tried recording it and it was dropping bits like crazy)
When I did enable this line...
FileLogger::append("GPS.txt", &val, 1);
I got this on the card...
¡4–^§ýõy9{´“ ïu)[Qs ÿÝÿÿÿéÿÿÿÇÿÿÿëÿÿÿ·}WW}§§£
Obviously I need to use a buffer. Could use help fixing that.
Thank you again!
Garrett