Hi all
I am writing an app to read the contents of a file stored on a USB key following the tutorial at:
http://www.arduino.cc/playground/Main/UsbMemory
However I am having a problem reading the data back using the RD command and can't seem to find any further references in the forum. Theoretically using the code below I should be capturing the first 4 bytes of the file contents and printing them out to the serial monitor but I am getting no feedback. Any help would be gratefully appreciated!
Cal
#include <SoftwareSerial.h>
/***********************************************
- The LightSpace is wired up thus:
- The USB outputs to Arduino PD3 (Pin Digital 3)
- The USB takes input from Arduino PD7
************************************************/
#define recievePin 3
#define transmitPin 7
// set up a new serial port
SoftwareSerial mySoftwareSerial = SoftwareSerial(recievePin, transmitPin);
int incomingChar;
void setup()
{
Serial.begin(57600);
Serial.println("working!");
pinMode(recievePin, INPUT);
pinMode(transmitPin, OUTPUT);
digitalWrite(transmitPin, HIGH);
delay(3000);
// set the data rate for the SoftwareSerial port
mySoftwareSerial.begin(9600);
mySoftwareSerial.print("IPA");
mySoftwareSerial.print(13, BYTE);
delay(5);
}
/***********************************************
************************************************/
void loop()
{
int n = 0;
if(n == 0)
{
n = 1;
mySoftwareSerial.print("OPR TIMTEST.TXT");
mySoftwareSerial.print(13, BYTE);
delay(1000);
mySoftwareSerial.print("RD TIMTEST.TXT");
mySoftwareSerial.print(13, BYTE);
incomingChar = mySoftwareSerial.read();
Serial.print(incomingChar, BYTE);
incomingChar = mySoftwareSerial.read();
Serial.print(incomingChar, BYTE);
incomingChar = mySoftwareSerial.read();
Serial.print(incomingChar, BYTE);
incomingChar = mySoftwareSerial.read();
Serial.print(incomingChar, BYTE);
delay(1000);
mySoftwareSerial.print("CLF TIMTEST.TXT");
mySoftwareSerial.print(13, BYTE);
delay(1000);
Serial.print("DIR");
mySoftwareSerial.print(13, BYTE);
}
}