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.
UARTFrame.h
00001 #ifndef SmartLab_MuRata_UARTFrame 00002 #define SmartLab_MuRata_UARTFrame 00003 00004 #include "Payload.h" 00005 #include "CommandID.h" 00006 00007 namespace SmartLabMuRata 00008 { 00009 /* 00010 * 7 | 6 | 5 4 3 2 1 0 00011 * SOM(0x02) 00012 * 1 | L0 00013 * 1 | A | L1 00014 * 1 | Command ID 00015 * Payload 00016 * ... 00017 * ... 00018 * 1 | Checksum 00019 * EOM(0x04) 00020 */ 00021 00022 /* 00023 * Each frame is delineated by a Start of Message (SOM) and End of Message (EOM) byte. The rest of the 00024 * fields are as follows: 00025 * The frame starts with a SOM (0x02) and ends with an EOM (0x04). The SOM and EOM values 00026 * may also appear in application payload. 00027 * Payload length (L1:L0): octet length of application payload including any escape characters. L0 00028 * stands for bit0 to bit6, and L1 stands for bit7 to bit12 of the payload length. 00029 * Command ID: specifies types of payload 00030 * A: 1 if ACK required, 0 if no ACK is required. If A=1, then the receiver must send ACK upon a 00031 * successful validation of the frame. A frame requiring acknowledgement must be acknowledged 00032 * Murata SW Design 00033 * Murata Proprietary Page 11 of 101 00034 * before any other non-response frame may be transmitted, i.e., a command response is always permitted. 00035 * Checksum: sum of L0, A | L1 and command ID. 00036 */ 00037 class UARTFrame 00038 { 00039 00040 private : 00041 char l0; 00042 char l1; 00043 00044 bool needACK; 00045 00046 CommandID commandid; 00047 00048 Payload * payload; 00049 00050 char checksum; 00051 00052 public : 00053 00054 static const char SOM = 0x02; 00055 static const char EOM = 0x04; 00056 00057 // length 00058 char GetL0(); 00059 00060 void SetL0(const int value); 00061 00062 char GetL1(); 00063 00064 void SetL1(const int value); 00065 00066 int GetPayloadLength(); 00067 00068 void SetPayloadLength(const int length); 00069 00070 // ack 00071 bool GetACKRequired(); 00072 00073 void SetACKRequired(const bool ack); 00074 00075 //command id 00076 CommandID GetCommandID(); 00077 00078 void SetCommandID(const CommandID id); 00079 00080 void SetCommandID(const int value); 00081 00082 // payload 00083 void SetPayload(Payload * payload); 00084 00085 Payload * GetPayload(); 00086 00087 // checksum 00088 char GetChecksum(); 00089 00090 void SetChecksum(const int checksum); 00091 00092 bool VerifyChecksum(); 00093 }; 00094 } 00095 00096 #endif
Generated on Fri Jul 15 2022 01:02:11 by
1.7.2