Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: tests/blocking/file/FileReadTest.cpp
- Revision:
- 0:836c9a6383e0
- Child:
- 1:5137ec8f4c45
diff -r 000000000000 -r 836c9a6383e0 tests/blocking/file/FileReadTest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/blocking/file/FileReadTest.cpp Mon Aug 11 11:31:32 2014 +0000 @@ -0,0 +1,57 @@ +/* + * Copyright 2014, ACKme Networks + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ACKme Networks; + * the contents of this file may not be disclosed to third parties, copied + * or duplicated in any form, in whole or in part, without the prior + * written permission of ACKme Networks. + */ + + + +#include "tests/Tests.h" +#include "Wiconnect.h" + + +static WiconnectResult readFile(File &file); + + + +/*************************************************************************************************/ +WiconnectResult fileReadCommand(int argc, char **argv) +{ + WiconnectResult result; + File file(512); + Wiconnect *wiconnect = Wiconnect::getInstance(); + + if(argc != 1) + { + LOG_ERROR("must specify file name to read"); + return WICONNECT_BAD_ARG; + } + + + if(!WICONNECT_FAILED(result, wiconnect->openFile(file, argv[0]))) + { + readFile(file); + } + + return result; +} + +/*************************************************************************************************/ +static WiconnectResult readFile(File &file) +{ + uint8_t *ptr; + uint16_t size; + + while(file.read(&ptr, &size) == WICONNECT_SUCCESS) + { + LOG_INFO("File data: (%d)\r\n", size); + logWrite(ptr, size); + } + + return WICONNECT_SUCCESS; +} +