Main Site Documentation

Read command


I have a file with 500 chars I want to read.

I first open the file for Read:
O 4R>U1:\Mercator\Text.TXT.
Respond is !00.

Then I read the first 5 chars:
R 4^>05.
Respond is

Then I want to read the next 5 chars:
R 4^>05

This tells me that the EOF is reached. But is not.
What I’m I doing wrong?


Could you show us the commands you used to initialize and mount the media? Are you using the SPI, I2C, or UART interface?


This is a copy of the hyperterminal program I use to debug my program.
It is just after the start of program.
I have a USb stick connected on U1.

The interface is UART.

GPS Logger V3.0
GHI Electronics, LLC

ALFAT SoC Processor
I U1:
@ U1:


Could you try to format the USB drive and see what happens? What size is the drive? If you try and read more than 5 characters the first time, does it work? Could you try to read all 500 and see if that works?


The size of the drive is 4,2 GB.

Writing to the drive is no problem.
Even copying files, renaming files, … no problem.

I just tested it: reading 150 chars: no problem.
The 500 chars was just a test to debug my program.
That’s why I was reading only 5 bytes at a time.
The file could be much shorter, or longer: it’s generated by the customer.

Some other interresting point:

  • the “Read Status Register” J command, always returns $00. Even when the U1 drive is mounted (and logging) or not.
  • the set “Current Time and date” S command does not work:
    When sending " S 34212002" (your example in the manual), it will return !00. But when you look at the Date created on a PC, it’s always 31 Dec 1978 23:00

I’m controlling the alfat module from a atXmega128



if you are using usb1, make sure it is initialized in HS mode.
For set date and time, call “T S” or “T B” first.

we confirm there is still a bug related to date/ time when it is saved to file, but but real time clock works correctly.

Edit: I do not have 4.2G USB, I just tested on 4G.