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.
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Diff: SnCommUsb.cpp
- Revision:
- 3:24c5f0f50bf1
- Parent:
- 2:e67f7c158087
- Child:
- 4:a91682e19d6b
diff -r e67f7c158087 -r 24c5f0f50bf1 SnCommUsb.cpp
--- a/SnCommUsb.cpp Tue Jul 24 02:07:23 2012 +0000
+++ b/SnCommUsb.cpp Tue Jul 31 04:59:16 2012 +0000
@@ -48,9 +48,38 @@
return ret;
}
+SnCommWin::ECommWinResult SnCommUsb::WaitHandshake(const uint32_t timeout,
+ char* const buf,
+ const uint32_t bsize) {
+ printf("WaitHandshake, to=%u\r\n",timeout);
+
+ bool hasData = fgCpu->readable()==1;
+
+ while ( (hasData==false) && (time(0) < timeout) ) {
+ wait_ms(10);
+
+ hasData = fgCpu->readable()==1;
+ }
+
+ if( hasData ) {
+ uint8_t mcode;
+ uint32_t mlen;
+ SnHeaderFrame::ReadFrom(*fgCpu, mcode, mlen);
+ if (mcode==SnHeaderFrame::kHandshakeCode) {
+ return SnCommWin::kOkWithMsg;
+ } else {
+ // TODO: somehow handle unexpected message?
+ return SnCommWin::kUnexpectedRec;
+ }
+ } else {
+ return SnCommWin::kOkNoMsg;
+ }
+}
+
SnCommWin::ECommWinResult SnCommUsb::GetConfig(SnConfigFrame& conf,
const uint32_t timeOut,
- char* const confBuf) {
+ char* const confBuf,
+ const uint32_t bsize) {
// confBuf not used by usb. bytes read directly from serial port
SnCommWin::ECommWinResult res = SnCommWin::kUndefFail;
@@ -77,6 +106,17 @@
return res;
}
+SnCommWin::ECommWinResult SnCommUsb::SendFilename(const char* fn, char* const genBuf) {
+ const size_t flen = strlen(fn);
+ bool ok = SnHeaderFrame::WriteTo(*fgCpu,
+ SnHeaderFrame::kFilenameCode,
+ SnHeaderFrame::SizeOf());
+ if (ok) {
+ ok = SendBytes(fn, flen);
+ }
+ return ok ? SnCommWin::kOkMsgSent : SnCommWin::kFailPartSent;
+}
+
SnCommWin::ECommWinResult SnCommUsb::SendStatus(const SnConfigFrame& conf,
const SnEventFrame& evt,
char* const genBuf) {