problem in copying bin file into buffer in my firmware download code
dear sir i am trying to download the firmware file in to my cypress USBcontroller FX2LP.but i think i am facing problem in copying that bin file in buf and dowloading it to the FX2LP
please help me i am pasting my whole code i have tried to print the buf len aslo but it doesnt match with the size of file please help me firmware doest get dowloaded in IC i am using some cyusb and its API of control transfer for doing this any more information needed please let me know Code:
#include <stdio.h> Thanks & regards rohan |
Dear rohaanembedded:
Do you have any error messages? Alejandro |
Dear sir,
Thanks for rply I get no error sir but by tried some things and right know i am getting right buffer filling but every time my control transfer is also returning the right no. of bytes sennt but after complition no effect on the device. the firmware i have chnages the VendorID and ProductID After firmware download any specific information needed plz let me know. do you know about cyusb wrapper its usb wrapper just like libusb actuallya developed on the same for cypress USBcontroller IC's pasting my edited code: Code:
#include <stdio.h> rohaan |
There have been several threads related to similar problems lately. Don't use buffered input if you're just reading binary data, and don't use string functions because binary data contains null characters. Use open, read, and write, and use the return value of read as the size of the buffered data. fopen, etc. is only necessary if you want libc to handle text parsing.
Kevin Barry |
Quote:
thanks for ur tome sir, Code:
ssize_t read(int fd, void *buf, size_t count); Code:
fp = fopen(const char *path, const char *mode); Regards, rohan |
Dear sir i have tried this with open() and read() but its not making any chnage plz give suggstions
Code:
#include <stdio.h> rohaan |
|
Quote:
i have done somthing like this, please do let me know where i am makin mistake. THe file size i know its 8192bytes so i have taken it hard coded in read call. like, size = read(fp_int, buf, 8192); Code:
rohan |
read shouldn't return -1 unless there's an error. Are you reading from a regular file? Also, the return value of read doesn't correspond to a size when that value is -1, so you shouldn't add it to the total in that case. In addition to breaking out of the loop, print strerror(errno) to see what the error is. As I implied before, certain errors merely mean that you need to try the call again (e.g. EINTR and EAGAIN.) The hard-coding doesn't help anything, and in fact you might as well just skip retrieving the file size, since it's redundant.
Kevin Barry |
All times are GMT -5. The time now is 12:16 PM. |