1st release (without comment)
RMS_UART.h@11:2e1543c03b22, 2016-09-20 (annotated)
- Committer:
- nsrwsurasak
- Date:
- Tue Sep 20 23:55:52 2016 +0000
- Revision:
- 11:2e1543c03b22
- Parent:
- 10:ec0470d18ea4
- Child:
- 12:3bbbabca6590
Change content buffer size to 1536
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nsrwsurasak | 1:5e6c5fbd48d6 | 1 | /** |
nsrwsurasak | 1:5e6c5fbd48d6 | 2 | ****************************************************************************** |
nsrwsurasak | 1:5e6c5fbd48d6 | 3 | * @file RMS_UART.cpp |
nsrwsurasak | 1:5e6c5fbd48d6 | 4 | * @author Surasak N |
nsrwsurasak | 9:025a189e5082 | 5 | * @version V2 |
nsrwsurasak | 9:025a189e5082 | 6 | * @date 20/09/2016 |
nsrwsurasak | 1:5e6c5fbd48d6 | 7 | * @brief Command for Mini-RMS <> RMS via UART |
nsrwsurasak | 1:5e6c5fbd48d6 | 8 | ******************************************************************************/ |
nsrwsurasak | 1:5e6c5fbd48d6 | 9 | |
nsrwsurasak | 0:bc10ea82aec3 | 10 | #ifndef RMS_UART_H |
nsrwsurasak | 0:bc10ea82aec3 | 11 | #define RMS_UART_H |
nsrwsurasak | 0:bc10ea82aec3 | 12 | |
nsrwsurasak | 0:bc10ea82aec3 | 13 | #define EXT_SERIAL 1 |
nsrwsurasak | 0:bc10ea82aec3 | 14 | #define MSG_BUF_SIZE 25 |
nsrwsurasak | 0:bc10ea82aec3 | 15 | #define MSG2CMD 2 |
nsrwsurasak | 0:bc10ea82aec3 | 16 | #define MSG2FILENAME (MSG_BUF_SIZE - MSG2CMD) |
nsrwsurasak | 11:2e1543c03b22 | 17 | #define CONTENT_BUF_SIZE 1536 |
nsrwsurasak | 1:5e6c5fbd48d6 | 18 | |
nsrwsurasak | 1:5e6c5fbd48d6 | 19 | #define CMD_END_OF_CONTENT "*end*" |
nsrwsurasak | 1:5e6c5fbd48d6 | 20 | #define CMD_LISTFILE "ls" |
nsrwsurasak | 1:5e6c5fbd48d6 | 21 | #define CMD_READFILE "rd" |
nsrwsurasak | 1:5e6c5fbd48d6 | 22 | #define CMD_WRITEFILE "ed" |
nsrwsurasak | 1:5e6c5fbd48d6 | 23 | #define CMD_DELETEFILE "df" |
nsrwsurasak | 1:5e6c5fbd48d6 | 24 | #define CMD_SYS_RESTART "rs" |
nsrwsurasak | 9:025a189e5082 | 25 | #define CMD_SYS_PAUSE "sp" |
nsrwsurasak | 4:cd5fb2575b50 | 26 | #define CMD_HELP "-h" |
nsrwsurasak | 9:025a189e5082 | 27 | #define CMD_CHECK_ERROR "ce" |
nsrwsurasak | 1:5e6c5fbd48d6 | 28 | |
nsrwsurasak | 1:5e6c5fbd48d6 | 29 | #define FOUND_CSV_FILE ".csv" |
nsrwsurasak | 1:5e6c5fbd48d6 | 30 | #define FOUND_XML_FILE ".xml" |
nsrwsurasak | 1:5e6c5fbd48d6 | 31 | #define FOUND_LOG_FILE ".log" |
nsrwsurasak | 0:bc10ea82aec3 | 32 | |
nsrwsurasak | 10:ec0470d18ea4 | 33 | #define _SPACE '\0' |
nsrwsurasak | 9:025a189e5082 | 34 | #define FLAG_STATUS_OK "OK" |
nsrwsurasak | 9:025a189e5082 | 35 | #define FLAG_STATUS_ERROR "ER" |
nsrwsurasak | 9:025a189e5082 | 36 | #define FLAG_STATUS_END "*END*" |
nsrwsurasak | 9:025a189e5082 | 37 | |
nsrwsurasak | 9:025a189e5082 | 38 | |
nsrwsurasak | 9:025a189e5082 | 39 | #define RMS_STATUS_LIST_OK "LK" |
nsrwsurasak | 9:025a189e5082 | 40 | #define RMS_STATUS_READ_OK "RK" |
nsrwsurasak | 9:025a189e5082 | 41 | |
nsrwsurasak | 0:bc10ea82aec3 | 42 | #define BPS_9600 9600 |
nsrwsurasak | 1:5e6c5fbd48d6 | 43 | |
nsrwsurasak | 1:5e6c5fbd48d6 | 44 | /** |
nsrwsurasak | 1:5e6c5fbd48d6 | 45 | * @brief Command request definition |
nsrwsurasak | 1:5e6c5fbd48d6 | 46 | */ |
nsrwsurasak | 1:5e6c5fbd48d6 | 47 | typedef enum { |
nsrwsurasak | 1:5e6c5fbd48d6 | 48 | REQ_NONE, /** None Type : UART do nothing */ |
nsrwsurasak | 1:5e6c5fbd48d6 | 49 | REQ_LISTDIR, /** Connect Type : List files as in directory */ |
nsrwsurasak | 1:5e6c5fbd48d6 | 50 | REQ_READ, /** Read Type : Read file as file name */ |
nsrwsurasak | 1:5e6c5fbd48d6 | 51 | REQ_WRITE, /** Write Type : Create/Write as file name and contens */ |
nsrwsurasak | 9:025a189e5082 | 52 | REQ_DELETE, /** Delete Type : Delete file as file name */ |
nsrwsurasak | 9:025a189e5082 | 53 | REQ_FLAG_OK, /** Flag OK Type " Send "OK" flag via UART */ |
nsrwsurasak | 9:025a189e5082 | 54 | REQ_READ_CHECK /** Read Check Type : Check available file as in SD card */ |
nsrwsurasak | 1:5e6c5fbd48d6 | 55 | } FileRequest_CMD_Type; |
nsrwsurasak | 0:bc10ea82aec3 | 56 | |
nsrwsurasak | 9:025a189e5082 | 57 | /** |
nsrwsurasak | 9:025a189e5082 | 58 | * @brief Error type definition |
nsrwsurasak | 9:025a189e5082 | 59 | */ |
nsrwsurasak | 9:025a189e5082 | 60 | typedef enum { |
nsrwsurasak | 9:025a189e5082 | 61 | EC_SUCCESS = 0, /** SUCCESS Type : Do not have an error */ |
nsrwsurasak | 9:025a189e5082 | 62 | EC_CMD_ERROR = 1, /** CMD_ERROR Type : Command not found */ |
nsrwsurasak | 9:025a189e5082 | 63 | EC_FILE_NOT_FOUND = 2, /** FILE_NOT_FOUND Type : File not available as in SD card */ |
nsrwsurasak | 9:025a189e5082 | 64 | EC_WRITE_ERROR = 3, /** WRITE_ERROR Type : Do not write the file */ |
nsrwsurasak | 9:025a189e5082 | 65 | EC_FILE_TOO_LARGE = 4 /** FILE_TOO_LARGE Type : Content is too large over buffer size */ |
nsrwsurasak | 9:025a189e5082 | 66 | } Error_Code_Type; |
nsrwsurasak | 9:025a189e5082 | 67 | |
nsrwsurasak | 1:5e6c5fbd48d6 | 68 | /* ############### Declare functions extern ################## */ |
nsrwsurasak | 1:5e6c5fbd48d6 | 69 | extern Serial serial_device; |
nsrwsurasak | 1:5e6c5fbd48d6 | 70 | extern FileRequest_CMD_Type reqFileCmdType; |
nsrwsurasak | 1:5e6c5fbd48d6 | 71 | extern char FileName[MSG2FILENAME]; |
nsrwsurasak | 1:5e6c5fbd48d6 | 72 | extern char Content_RxBuf[CONTENT_BUF_SIZE + 1]; |
nsrwsurasak | 2:38567b4310a4 | 73 | extern bool MsgContentManagement; |
nsrwsurasak | 9:025a189e5082 | 74 | extern Error_Code_Type gErrorCode; |
nsrwsurasak | 9:025a189e5082 | 75 | |
nsrwsurasak | 1:5e6c5fbd48d6 | 76 | |
nsrwsurasak | 1:5e6c5fbd48d6 | 77 | /* ############### Function Prototype ################## */ |
nsrwsurasak | 1:5e6c5fbd48d6 | 78 | /** |
nsrwsurasak | 1:5e6c5fbd48d6 | 79 | * @note The detail as RMS_UART.cpp |
nsrwsurasak | 1:5e6c5fbd48d6 | 80 | */ |
nsrwsurasak | 1:5e6c5fbd48d6 | 81 | void Init_SerialDevice(); |
nsrwsurasak | 0:bc10ea82aec3 | 82 | void RxMsgInterruptCallback(); |
nsrwsurasak | 0:bc10ea82aec3 | 83 | void DoTheMsgCmd(); |
nsrwsurasak | 0:bc10ea82aec3 | 84 | void DoTheContent(); |
nsrwsurasak | 0:bc10ea82aec3 | 85 | void GetListFileCmd(); |
nsrwsurasak | 0:bc10ea82aec3 | 86 | void CheckReadEditCmd(); |
nsrwsurasak | 0:bc10ea82aec3 | 87 | void GetFileName(); |
nsrwsurasak | 0:bc10ea82aec3 | 88 | void SendContentToFile(); |
nsrwsurasak | 0:bc10ea82aec3 | 89 | void GetCmdError(); |
nsrwsurasak | 0:bc10ea82aec3 | 90 | void ClearCmdIndexAndBuf(); |
nsrwsurasak | 0:bc10ea82aec3 | 91 | void ClearContentIndexAndBuf(); |
nsrwsurasak | 1:5e6c5fbd48d6 | 92 | void CheckContentMsg(); |
nsrwsurasak | 2:38567b4310a4 | 93 | void ClearFileNameBuf(); |
nsrwsurasak | 1:5e6c5fbd48d6 | 94 | void CheckCmdType(); |
nsrwsurasak | 1:5e6c5fbd48d6 | 95 | void ClearFileNameBuf(); |
nsrwsurasak | 4:cd5fb2575b50 | 96 | void GetHelpCmd(); |
nsrwsurasak | 0:bc10ea82aec3 | 97 | |
nsrwsurasak | 1:5e6c5fbd48d6 | 98 | #endif /* End of RMS_UART_H */ |