UCMD_FILEREAD documentation problem
The Spectran API Documentation states the following:-
The UCMD_FILEREAD command reads a file block. The command is followed by 2 bytes fileid and 2 bytes offset. The offset is in words, not bytes. The Command responds with UST_FILESTAT followed by a status byte. If the status byte is USFT_DONE, the command is followed by UST_FTREADDAT, 1 byte data lenght in words (not bytes) and data.
0x10 id id offset offset
0x12 Len data ....
The status value UFST_DONE indicates successfull execution of the request, read requests are followed by a UST_FTREADDAT command response. The status value UFST_NOTFND indicates that the file doesn’t exist, the status value UFST_FSFULL indicates full file system (for write commands only), the status command UFST_ACCERR indicates a general Spectran internal error.
There are a couple of problems here:
1/ There is no mention of where you retrieve a FileID from. I have read the UK manual for the Spectran HF-6085 and guessed that the only file ID that can be used at the moment is "1000". I this correct and what facilities exist to retrieve fileID's
2/*BIG PROBLEM* UST_FILESTAT is the only value that is actually defined anywhere in the example code. There is no way of checking the returned status without knowing these values.
there is no API call that retrieves a list of available files. You have to evaluate the status returned by UCMD_FILEREAD for the file id's from 0 to 9999 to determine whenever a file exists or not. The preprocessor macros are defined in "usbcmd.h", "lclfsetv.h", "mcssetv.h and "lcssetv.h".
Thanks for that.
Yes, I found the definitions eventually - having a project file would have been easier
Can I suggest that you remove the version 14 code from the downloads area? If it is known that it doesn't work then leaving it for download will result in someone else having the same problems I've been having!
We are about to merge the two domains aaronia.de and spectran-developer.net these days and software/SDK downloads will be available only at spectran-developer.net then.
For historical reasons, a copy of version 14 has to remain on line (even at spectran-developer.net), but we try to ensure, that developers find the latest version most easily.
I still have problems with this file reading. The API documentation states that I should send a bytes set consisting of CMD, lowbyteID, highByteID, offsetbyte, offsetbyte - what function from usbconnector is supposed to cover this format? What are the offsets for? Am I supposed to repeat the UCMD_FILEREAD applying the bytes read from FTREADDAT (if I can get that far) as the offset each time?
Can you give me an example of how to read the file with file ID 1000 (as determined from running the LCS analyser).
I attempted to use writebytes() but it returns the number of bytes written and not a status.
Is there another docuemnt I should be using as well as the API document?
Any help would be greatly appreciated.
You have to read the return status, UST_FILESTAT(0x10), from the device and evaluate the value according to:
/* USB file handling status codes (USBCMD.H - 59)*/ #define UFST_DONE 0x00 /* File operation done */ #define UFST_NOTFND 0x01 /* File or section not found error */ #define UFST_FSFULL 0x02 /* File system full error */ #define UFST_ACCERR 0x03 /* File system access error */
Only that many bytes can be transfered at once, therefore an absolute virtual offset into the file is used.
e.g. reading a 768 byte file, but having a FTMAXSIZE of 256 byte, would require 3 read operations. The offsets would be 0, 256 and 512.
Sorry if I'm not being clear here but this still doesn't answer my question - which put as simply as I can is:-
How do I use usbconnector.cpp to send the UCMD_FILEREAD command....
0x10 id id offset offset
.....mentioned in the API document?
I need to send this before I can read any status!
It seems we were both busy yesterday - I wrote a VB App that talks directly to the FTD2xx.dll in order to read the file.
The API guide could use a bit more information on the returned data format, I know it says "...1 byte data lenght in words (not bytes) and data...." (which I miss-read initially), but the actual data itself could be better explained e.g.
"The raw data represents data point pairs for decibel measurement and the frequency it was measured at. The first 2 bytes ( or word) are the dB level and the 3rd and 4th bytes the associated frequency. The word values should be converted to signed integers."
There may be a case for mentioning the fact that even this conversion isn't completely correct as a signed integer of -7411 is actually a dB of -74.11
Anyway, I'm sure there are plenty of other people out there that can help with feedback for the ASDK
Thanks for all your help in this matter. No doubt you'll see me again