Issues with the Read fonction

Hi there !

For my project , I have to work with an ALFAT2. On my system, I have an ST7 who commands the ALFAT2 using SPI . I wrote some codes to execute basic command like V,J,etc and it works perfectly.
But when I launch “R” , the ALFAT2 relaunch the byte in two step !
For example, I ask to read 20 bytes and I have only “!00\nmy20bytes”. I have to re-execute the command and then I can have the rest of the message.( which is “$000000020\n!00\n”).

Do you have any explication ?

20 is not 20 bytes. This is a hexadecimal number.

Yes sorry I receive 32 bytes , which is still correct ^^

I took screenshot to illustrate:

First, i send to the Alfat2 my order : (I opened my file in read mode before with sucess) :

Then the response i have from the Alfat2 is :

The text is correct, but the end of the message (“$00000020\n!00\n”) is missing !

1 Like

Oh may be I can add image ?

@ BC_FR -

If you request for 32 bytes (0x20) then ALFAT will respond totally 4 +32 + 10 + 4. You have to read totally 50 bytes.
How do you know it is missing? Try send V command after that and read the respond so see what happens.

Well the size of the buffer is exactly 50 bytes ^^ I tried to read only 5 bytes and it’s the same thing :confused:

Whatever I took screen with the other command wich are send .As you can see it works !

What do you mean when say “the size of the buffer is exactly 50 bytes ^^ I tried to read only 5 bytes”?
So you didn’t read 45 byte left?

Your buffer size is not important here, it still works even your size has only 1 byte size. The important is, after sent Read Command for 0x20 bytes, how many bytes ALFAT did respond to you (check the 2nd and 3rd byte when you sent SPI READ FRAME)

For 0x20 bytes, ALFAT respond with 0x24 bytes, wich is equal as the situation in my second post .
For 0x5 bytes, ALFAT respond with 0x9 bytes.

And so ALFAT doen’t respond the good number of bytes, because in the datasheet (wich is very readable btw :slight_smile: ) it says that the sequence of bytes send by the alfat is :
!00\n
mybytesaskedfor$aaaaaaaa\n
!00\n

And as you can see in my second post , the bytes send by ALFAT correspond as “!00\nmybytes”. That’s why I can say that the rest, wich is “$aaaaaaaa\n!00\n” , is missing !

@ BC_FR -

[quote]For 0x20 bytes, ALFAT respond with 0x24 bytes, wich is equal as the situation in my second post .
For 0x5 bytes, ALFAT respond with 0x9 bytes.[/quote]

Delay a bit then repeat reading again, those bytes may come later.
Or, please test this:

  • Send Read command for 0x5 bytes
  • Do not read, send V command
  • Delay a second, then read the respond.

Tell us what you have then.

This is what I get :

I increased my tempo ( it’s around 1 sec now). It seems the “V” command unblock my ALFAT.

@ BC_FR -

V command should return “v2.0.0…”, not “JE SU”, I guess this is in your files.
What I can say is something wrong with the way you read.
Also, how did you send a request for 5 bytes? “0x02, 0x05, 0x00” or “0x02, 0x00, 0x05”. I think you sent to request more than 0x5 bytes (or 0x20) so instead of respond “$xxxxxxxx\n!00\n”, data is still coming, easy to see is V command returned “JE SU” instead of “v2.0.0…”, or your buffer has something wrong.

Hello,

i have the same problem.

i use alfat 428, when i read a file i have only !00 and i receve ABCDE (correct) only when i send C 1.

i cant read all the bytes before sending C 1

someone can help me ?

@ Mick007 -

After you read ‘!00’, delay a bit, then you should read next 18 bytes, ALFAT will give you all “ABCDE$00000005\r!00”.
Problem is, after you sent “R” commmands, “!00” is sent immediately, that is you can have it.
But next 18 bytes takes more time, because it must be loaded from media, and it is only available after you read “!00”.