-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendFrame.h
46 lines (38 loc) · 900 Bytes
/
sendFrame.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// sendPacket.h
//
//
// Created by Akmal Fadlurohman on 10/16/17.
//
//
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifndef sendFrame_h
#define sendFrame_h
#define sendFrame_size 9
typedef struct {
uint8_t SOH;
unsigned int seqNum;
uint8_t STX;
uint8_t data;
uint8_t ETX;
uint8_t checksum;
} sendFrame;
/* Initialization Method */
void initFrame(sendFrame *F);
void BytesToFrame(sendFrame *F,char* Bytes);
/* Getter Method */
unsigned int getSeqNum(sendFrame F);
uint8_t getData(sendFrame F);
uint8_t getChecksum(sendFrame F);
/* Setter Method */
void setSeqNum(sendFrame *F,unsigned int seqNum);
void setData(sendFrame *F,char c);
void setCheckSum(sendFrame *F,uint8_t checksum);
/* Frame and Byte Conversion Method */
char* sendFrameToByte(sendFrame *F);
void printBytes(char* Bytes);
/* Other Method */
uint8_t checkSum(sendFrame F);
#endif