An example program for SerialFileTransfer, receives files from a java application and stores them on the LocalFileSystem
Dependencies: MODSERIAL SerialFileTransfer SimpleSerialProtocol mbed
SerialFileReceiver allow the mbed to receive a file using binary packets over the serial connection,
you can test the library with this java application /media/uploads/p3p/mbedserialfiletransfer.zip
the arguments to the command are, Comport Baudrate file to see the console output use java, not javaw
Example command: java -jar SerialTransfer.jar com3 115200 test.bin
main.cpp
- Committer:
- p3p
- Date:
- 2014-08-27
- Revision:
- 0:a0abf3eff698
- Child:
- 3:116c45e2a41e
File content as of revision 0:a0abf3eff698:
#include "mbed.h" #include "SerialFileTransfer.h" //Create an instance of the SimpleSerialProtocol on a Serial port, optionaly choose a status led SimpleSerialProtocol::Protocol comms(USBTX, USBRX, LED1); Serial debug(p13,p14); SFTProtocol fileAcceptor; int main() { //initialise the comm port at 155200 baud comms.initialise(115200); //listen for packets of type 1 and relay the data to the onFileStart callback in SFTProtocol comms.receiveCallback(1, &fileAcceptor, &SFTProtocol::onFileStart); //listen for packets of type 3 and relay comms.receiveCallback(3, &fileAcceptor, &SFTProtocol::onFileStream); debug.baud(115200); debug.printf("Debug Terminal:\r\n"); while(true){ //the protocol needs constant updates to process packets and forward the data comms.update(); //the SFTProtocol is updated so it can timeout, and request packet resends, fileAcceptor.update(&comms); } }