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.
Revision 20:e0302dc43412, committed 2018-12-15
- Comitter:
- hyunsungkim
- Date:
- Sat Dec 15 19:32:26 2018 +0000
- Branch:
- RF24_library_test_tx
- Parent:
- 19:6f01eb6f4163
- Commit message:
- before adjusting communication timing
Changed in this revision
master.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/master.cpp Sat Dec 01 19:32:07 2018 +0000 +++ b/master.cpp Sat Dec 15 19:32:26 2018 +0000 @@ -39,7 +39,6 @@ } payload_t; void beepStart(); -void endBeep(); void initNRF(int mode, int msg_len); void dumpRFInfo(); int readSerialUntil(char *buffer, unsigned int buf_len, char terminator); @@ -54,17 +53,16 @@ pc.baud(115200); printf("I'm Master\r\n"); initNRF(NRF_TRANSMIT, TRANSFER_SIZE); -// dumpRFInfo(); - + dumpRFInfo(); memset(buffer, NULL, BUFFER_SIZE); while(1) { - int result = readSerialUntil(buffer, BUFFER_SIZE, DATA_PROTOCOL_END); - if(result>0) { + int inByteNum = readSerialUntil(buffer, BUFFER_SIZE, DATA_PROTOCOL_END); + if(inByteNum>0) { char *data = inspectData(buffer, BUFFER_SIZE); if(*data == DATA_PROTOCOL_BEGIN) { payload_t *payload = getPayload(data); - printf("Sent - BotID:%d, CmdID:%d, LSpeed:%d, RSpeed:%d\r\n", payload->bot_id, payload->cmd_id, payload->lspeed, payload->rspeed); + printf("Payload - BotID:%d, CmdID:%d, LSpeed:%d, RSpeed:%d\r\n", payload->bot_id, payload->cmd_id, payload->lspeed, payload->rspeed); int n = transmitCmd(payload); free(data); free(payload); @@ -98,12 +96,14 @@ int rxDataCnt=0; char rxData[MAX_BUFFER_SIZE]; char buf[TRANSFER_SIZE]; + //char buf_[TRANSFER_SIZE]="$01,22,-51,11"; while(trial<NRF_RETRIAL_MAX) { initNRF(NRF_TRANSMIT, TRANSFER_SIZE); constructString(buf, p); nrf.write(NRF24L01P_PIPE_P0, buf, TRANSFER_SIZE); + //nrf.write(NRF24L01P_PIPE_P0, _buf, TRANSFER_SIZE); initNRF(NRF_RECEIVE, TRANSFER_SIZE); wait(0.01); rxDataCnt = nrf.read( NRF24L01P_PIPE_P0, rxData, TRANSFER_SIZE); @@ -219,25 +219,8 @@ } } /* -void getPayload(int id, unsigned int count, int lspeed, int rspeed, char* txData) -{ - *(txData+0) = '$'; - *(txData+1) = id/10+'0'; - *(txData+2) = id%10+'0'; - *(txData+3) = count/10000+'0'; - *(txData+4) = count/1000%10+'0'; - *(txData+5) = count/100%10+'0'; - *(txData+6) = count/10%10+'0'; - *(txData+7) = count%10+'0'; - *(txData+8) = lspeed>0?'+':'-'; - *(txData+9) = abs(lspeed)/10+'0'; - *(txData+10) = abs(lspeed)%10+'0'; - *(txData+11) = rspeed>0?'+':'-'; - *(txData+12) = abs(rspeed)/10+'0'; - *(txData+13) = abs(rspeed)%10+'0'; - *(txData+14) = '\0'; -} -xxyyyyyabbcddn + +$xxyyyyyabbcddn 14 chars