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@0:729795414ebd, 2022-10-05 (annotated)
- Committer:
- piroro4560
- Date:
- Wed Oct 05 01:05:52 2022 +0000
- Revision:
- 0:729795414ebd
- Child:
- 1:303170592014
make
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| piroro4560 | 0:729795414ebd | 1 | /** |
| piroro4560 | 0:729795414ebd | 2 | * @file FEP_TX22.cpp |
| piroro4560 | 0:729795414ebd | 3 | * @brief 送信用FEPライブラリ |
| piroro4560 | 0:729795414ebd | 4 | * @author 安澤瑠 |
| piroro4560 | 0:729795414ebd | 5 | * @date 22/10/4 |
| piroro4560 | 0:729795414ebd | 6 | */ |
| piroro4560 | 0:729795414ebd | 7 | #include "FEP_TX22.h" |
| piroro4560 | 0:729795414ebd | 8 | |
| piroro4560 | 0:729795414ebd | 9 | FEP_TX22::FEP_TX22(PinName tx, PinName rx, uint8_t addr_, int baud) : |
| piroro4560 | 0:729795414ebd | 10 | RawSerial(tx, rx, baud) |
| piroro4560 | 0:729795414ebd | 11 | { |
| piroro4560 | 0:729795414ebd | 12 | addr = addr_; |
| piroro4560 | 0:729795414ebd | 13 | } |
| piroro4560 | 0:729795414ebd | 14 | |
| piroro4560 | 0:729795414ebd | 15 | int8_t FEP_TX22::SendData(uint8_t *data) |
| piroro4560 | 0:729795414ebd | 16 | { |
| piroro4560 | 0:729795414ebd | 17 | uint8_t sendindex; // index of 'data' |
| piroro4560 | 0:729795414ebd | 18 | printf("@TBN%03d%03d", addr, DATANUM); // send comand |
| piroro4560 | 0:729795414ebd | 19 | for (sendindex=0; sendindex<DATANUM; sendindex++) { |
| piroro4560 | 0:729795414ebd | 20 | putc(data[sendindex]); // |
| piroro4560 | 0:729795414ebd | 21 | } |
| piroro4560 | 0:729795414ebd | 22 | printf("\r\n"); // <cr><lf> |
| piroro4560 | 0:729795414ebd | 23 | return 0; |
| piroro4560 | 0:729795414ebd | 24 | // return GetResponse(); |
| piroro4560 | 0:729795414ebd | 25 | } |
| piroro4560 | 0:729795414ebd | 26 | |
| piroro4560 | 0:729795414ebd | 27 | int8_t FEP_TX22::GetResponse() |
| piroro4560 | 0:729795414ebd | 28 | { |
| piroro4560 | 0:729795414ebd | 29 | char res[256]; // array of storing response |
| piroro4560 | 0:729795414ebd | 30 | for (uint8_t resindex=0; resindex<256; resindex++) { |
| piroro4560 | 0:729795414ebd | 31 | res[resindex] = getc(); |
| piroro4560 | 0:729795414ebd | 32 | if (!strncmp(res+resindex-1, "\r\n", 2)) { |
| piroro4560 | 0:729795414ebd | 33 | if (!strncmp(res+resindex-3, "P0", 2)) return 0; |
| piroro4560 | 0:729795414ebd | 34 | else if (!strncmp(res+resindex-3, "N0", 2)) return 2; |
| piroro4560 | 0:729795414ebd | 35 | else if (!strncmp(res+resindex-3, "N1", 2)) return 3; |
| piroro4560 | 0:729795414ebd | 36 | else if (!strncmp(res+resindex-3, "N3", 2)) return 4; |
| piroro4560 | 0:729795414ebd | 37 | } |
| piroro4560 | 0:729795414ebd | 38 | } |
| piroro4560 | 0:729795414ebd | 39 | return -1; |
| piroro4560 | 0:729795414ebd | 40 | } |