Why can't I read 512 bytes from a file ?

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys,

I tried to read 512 bytes from a file with FatFS,
When I read 512 bytes from a text file, it was ok,
but by the time I read from Mp3 file,
I got only the first 3 bytes of the file,

Anyone knows why ? or there's another trick to read mp3 files ?

Thanks

if (f_open(&Fil, "air1.mp3", FA_READ) == FR_OK)
	 {
	 f_read(&Fil, line, sizeof line, &bw);
 usart_pstr("\n\nReading file 512 bytes \n\n");
		 
		 usart_pstr(line);
		 f_close(&Fil);
 usart_pstr("\n\nFinished reading 512 bytes\n\n");
	 }
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

on text file :

 /*TESTING READING 512 bytes begin*/
	 if (f_open(&Fil, "lorem.txt", FA_READ) == FR_OK)
	 {
		 f_read(&Fil, line, sizeof line, &bw);
		 usart_pstr("\n\nReading file 512 bytes \n\n");
		 
		 usart_pstr(line);
		 f_close(&Fil);
		 usart_pstr("\n\nFinished reading 512 bytes\n\n");
	 }
	 /*TESTING READING 512 bytes end*/	

Last Edited: Sun. Mar 16, 2014 - 11:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There's probably null bytes in the data. Dump the data in hex, or use a tool on the pc to show the data in hex and look for bytes of 00

How did you go with the dht11?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On DHT11, I can send the request but the response it's not right yet, I can't see a proper response either on scope or logic analyzer, I didn't get it, since it's working allright on my arduino, but not on atmega128, do you have any init code for it ? I tried some examples from the web, but didn't work, and trying to rewrite it myself based from its datasheet....

Attachment(s):