-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathManager.h
134 lines (111 loc) · 3.06 KB
/
Manager.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#pragma once
#ifndef __MANAGER_H__
#define __MANAGER_H__
#include "Result.h"
namespace Manager
{
/**
* @brief Waits for a single byte to become available on the serial interface
* @return Byte read or error
*/
Result WaitReadByte();
/**
* @brief Waits for 2 byte short integer to become available on the serial interface
* @return Byte read or error
*/
Result WaitReadWord();
/**
* @brief Waits for 4 byte integer to become available on the serial interface
* @return Byte read or error
*/
Result WaitReadInt();
/**
* @brief Reads an escaped byte from the serial interface or resulting code.
* @return The data to be read or error code
*/
Result WaitReadDataByte();
/**
* @brief Reads a single byte from the serial port and compares with the specified value
* @return Data if expected value returned or error code
*/
Result Expect(int value);
/**
* @brief Sees if there is a byte available on the serial line that will cancel the operation
* @return bool True if cancelled
*/
bool ReadCancel();
/**
* @brief Sends failure if result is error
* @param result
* @return true if is error
*/
bool Error(Result result);
/**
* @brief Sends failure if error code is error
* @param errorCode
* @return true if is error
*/
bool Error(ResultType errorCode);
/**
* @brief Sends failure to the manager
* @param errorCode Error code to send
*/
void SendFailure(ResultType errorCode);
/**
* @brief Sends success/acknowledgement to the manager
*/
void SendSuccess();
/**
* @brief Start a data packet transmission
*/
void StartFrame();
/**
* @brief Sends an escaped data packet byte
* @param value Byte to send
*/
void SendFrameByte(int data);
/**
* @brief End data packet transmission
*/
void EndFrame();
/**
* @brief Send a byte to the manager
* @param data Value to send
*/
void SendDataByte(int data);
/**
* @brief Send the device select to the manager
* @param device The device code
*/
void SendDeviceSelect(int device);
/**
* @brief Send the print character
* @param data Character to print
*/
void SendPrintChar(int data);
/**
* @brief Sends the disk command start
*/
void StartDiskCommand();
/**
* @brief Initializes the buffer for reading
* @param totalSize The total amount of data to read in BUFFER_SIZE packets
*/
void InitializeBuffer(int totalSize);
/**
* @brief Reads a byte from the buffer, fills the buffer as necessary.
* @param timeout Number of milliseconds to wait for byte from the buffer
* @returns A byte from the buffer or an error code
*/
Result ReadBufferByte(int timeout = 0);
/**
* @brief Fills serial buffer
*/
void FillBuffer();
/**
* @brief Process incoming commands
* @return The processed command
*/
void Task();
}
#endif