Main Site Documentation

Accessing ALFAT via PC and Micro-Controller


#1

Hello,

I started playing around with my ALFAT developer kit and I am having difficulties. What I would like to do is to read/write data to the flash card in the ALFAT with a PC in addition to being able to read/write data with my micro-controller in the system.

Is there a way to have the ALFAT system show up as a drive on the PC side that I can go in and manipulate files?

Thank you


#2

@ shanemm -

ALFAT 2.0 can do that.

Insert your flash card, init ALFAT by “I U1:D” (I don’t remember exactly), then file system will be shown in PC if connected. Refer ALFAT 2.0 docuemt for more details


#3

Thanks for your prompt response Dat.

Is “I U1:D” a command that has to be executed in a program? I can get the ALFAT to show up as a device but not open it to manipulate the files.


#4

@ shanemm -

This command will change USB port 1 from HOST to Device.
Insert flash sd before calling this command.
At this time ALFAT has another function same as SD Card reader. Is this what you wanted?


#5

I see now what you are talking about and have picked up a few of the commands for the ALFAT. I can initialize an SD card, initialize the files and folders (somewhat), and open a file and assign a handle to it.

But now I am stuck at how to read and write to the file. For example I put a file on the SD card named “ANALOGG.CSV” and am able to open it for reading/writing but I am confused as to how I can get/put important information on the SD card. So in the ALFAT Explorer I have:

I M:
[strong]!00[/b]

O 1R>M:\ANALOGG.CSV
!00
R 1Z>10
!00
ZZZZZZZZZZ$00000000

But this file is pre-loaded with a bunch of different values that I want to read. Am I doing something wrong here or can ALFAT not read the contents of my file?

Also, if you could clarify the write process for me that would be awesome. This is what I entered into the ALFAT Explorer:

O 1W>M:\ANALOGG.CSV
!00
W 1>10
!00
1100110011
$10 (at this point I pressed “Read Line” multiple times before realizing I was doing something wrong)
$00001010 (I wanted to write 10 numbers (1100110011) so I figured 00001010 is binary for 10)
$00000010
!00
!02 (I tried to “Read Line” again)
C 1
!00

After this I tried to read it back and had moderate success:

O 1R>M:\ANALOGG.CSV
!00
R 1x>00001010 (again I figured 00001010 is binary for 10 and that is how many characters I wanted read back to me)
!00
1100110011

Success! Until I tried to close the file:

C1
$10
$XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX$00000010
!00

I’m not exactly sure how many X’s but it’s a lot (I can’t copy and paste from the text box). So it looked like I successfully wrote to the file and read it back. Except that the file I was opening already had information in it that I would rather read and write over.

Any guidance here would be appreciated.

Thank you,
Shane


#6

That is because you are thinking 10 in decimal, but in ALFAT, all number are in hex.

When you write “W 1>10” => you need to input 16 bytes data.

Then everything will be correct! I think.

Let us know if have any more issue.
Also try to check your version. To meet your requirement about SD Reader card, it is only supported on ALFAT 2.0


#7

Oh I see. So can you explain to me exactly what is going on in these few lines of code:

R 1Z>10
!00
1100110011
$10
$$00000010
!00

According to what you’re saying I would think that the output from reading the card would be:

ZZZZZZ1100110011

Because 10 in hex translates to 16 digits. I do not understand what the “$10” represents or the next line “$$00000010”


#8

@ shanemm -

[quote]
According to what you’re saying I would think that the output from reading the card would be:

ZZZZZZ1100110011[/quote]

No, it should be “1100110011ZZZZZZ”.

[quote]
I do not understand what the “$10” represents or the next line “$$00000010”[/quote]

Check you receive buffer or data in your file. It may your configuration still not correct.


#9

Thank you for all your help Dat, I think I am getting close to accomplishing what I want with the ALFAT file system. Here is what I need to do now:

I would like to read/write data to files on a CompactFlash card (or any other form of flash storage if necessary). These files are loaded with 100 seperate values in a .CSV format. In the experiment below I tried to retrieve data from a file through ALFAT but all I get back is filler characters when I should have received data I pre-loaded into the card.

Ideally, what I need to do is go into one of my files (such as ANALOGG.CSV) and pull out one of the values (ie. the 55th value) which will be used by a microprocessor. Is that possible or will I need to read the entire file?


#10

having no knowledge of ALFAT, I would do the “smarts” of reading the 55th value (or whatever) in the microcontroller. That’s just a set of read commands, and intelligently parsing the data. ALFAT to me is a storage abstraction layer, and it’d be unusual to have file content parsing capability there, so deal with that outside the storage layer.


#11

[quote]
In the experiment below I tried to retrieve data from a file through ALFAT but all I get back is filler characters when I should have received data I pre-loaded into the card.[/quote]

Are you saying ALFAT gave you data that is different with data in your file? Some software will show data in character, example instead of 97, it can be shown character ‘a’ but actually they are one.

[quote]
Ideally, what I need to do is go into one of my files (such as ANALOGG.CSV) and pull out one of the values (ie. the 55th value) which will be used by a microprocessor. Is that possible or will I need to read the entire file?[/quote]

You can do that if you know where its location is. Use ‘P’ - file seek to jump to anywhere you want in that file.


#12

Yes I had information in the file I was using above (100 seperate values) but when I tried to read it I only got place holders.

Then I wrote to the file as described above, which ALFAT read back to me. Do you think it could be some type of error with the format of the files or we need another driver of some sort?

I will attempt to use the P command, otherwise I’m sure we can work something out using the processor to obtain the correct data within a file.


#13

@ shanemm -

What does that mean, please?

[quote]Then I wrote to the file as described above, which ALFAT read back to me. Do you think it could be some type of error with the format of the files or we need another driver of some sort?

I will attempt to use the P command, otherwise I’m sure we can work something out using the processor to obtain the correct data within a file.[/quote]

ALFAT does not know, also does not care what format of the file is. ALFAT also does not care the file contents.

What interface are you using? I mean SPI, UART or I2C?

And what is your problem exactly now?