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.
Dependents: 2022_FEPTX-PS4 2022_FEPTX-TokiPS4
FEP_TX22.cpp
- Committer:
- piroro4560
- Date:
- 2022-10-06
- Revision:
- 1:303170592014
- Parent:
- 0:729795414ebd
File content as of revision 1:303170592014:
/** * @file FEP_TX22.cpp * @brief 送信用FEPライブラリ * @author 安澤瑠 * @date 22/10/6 */ #include "FEP_TX22.h" FEP_TX22::FEP_TX22(PinName tx, PinName rx, uint8_t addr_, int baud) : RawSerial(tx, rx, baud) { addr = addr_; } int8_t FEP_TX22::SendData(uint8_t *data, uint8_t datalen) { uint8_t sendindex; // index of 'data' printf("@TBN%03d%03d", addr, datalen); // send comand for (sendindex=0; sendindex<datalen; sendindex++) { putc(data[sendindex]); // } printf("\r\n"); // <cr><lf> return 0; // return GetResponse(); // 他にgetc()をループさせている場合に不具合確認 } int8_t FEP_TX22::GetResponse() { char res[256]; // array of storing response for (uint8_t resindex=0; resindex<256; resindex++) { res[resindex] = getc(); if (!strncmp(res+resindex-1, "\r\n", 2)) { if (!strncmp(res+resindex-3, "P0", 2)) return 0; else if (!strncmp(res+resindex-3, "N0", 2)) return 2; else if (!strncmp(res+resindex-3, "N1", 2)) return 3; else if (!strncmp(res+resindex-3, "N3", 2)) return 4; } } return -1; }