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
Diff: FEP_TX22.cpp
- Revision:
- 0:729795414ebd
- Child:
- 1:303170592014
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/FEP_TX22.cpp Wed Oct 05 01:05:52 2022 +0000
@@ -0,0 +1,40 @@
+/**
+ * @file FEP_TX22.cpp
+ * @brief 送信用FEPライブラリ
+ * @author 安澤瑠
+ * @date 22/10/4
+ */
+#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 sendindex; // index of 'data'
+ printf("@TBN%03d%03d", addr, DATANUM); // send comand
+ for (sendindex=0; sendindex<DATANUM; sendindex++) {
+ putc(data[sendindex]); //
+ }
+ printf("\r\n"); // <cr><lf>
+ return 0;
+// return GetResponse();
+}
+
+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;
+}
\ No newline at end of file