-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstructions.txt
186 lines (145 loc) · 8.91 KB
/
instructions.txt
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
##################################################
# Machine Intelligence Laboratory
# University of Florida, Gainesville, FL
##################################################
# Spring 2024 Software Team Application
##################################################
Welcome to the Spring 2024 Software Team Application! We are excited that you are
interested in joining the team. This application is designed to test your ability
to implement a simple serial driver that processes incoming packets and delivers
return response packets according to the packet received.
Please don't be frightened by the complexity of the exercise. It is 100% okay
if you are unable to fully complete it, and we expect many members will not be able
to do so. We are simply looking for a good faith effort and a demonstration of
your ability to learn and implement new concepts.
We hope that you enjoy this exercise. We are here to support you throughout your
application and your time in the laboratory! We hope that you are excited to work
at the Machine Intelligence Laboratory, and we look forward to reviewing your
application.
If you have any questions, please feel free to contact the MIL software leaders
through the laboratory Discord, or email:
- cbrown14@ufl.edu
- andrew.knee@ufl.edu
~ Andrew Knee and Cameron Brown
##################################################
# Challenge Objective
##################################################
For your assessment, you will be implementing a simple simulated serial driver that processes
incoming packets and delivers return response packets according to the packet received.
You can use either Python or C++ to complete this challenge, and can complete the
specifications according to any code structure you prefer. You do not need any external
libraries to complete this challenge. However, if you do use external libraries, please
include a requirements.txt file or a list of dependencies in your README.
You will be assessed on the following criteria:
- Correctness of implementation
- Code quality (readability, efficiency, modularity, etc.)
- Documentation (only simple documentation needed)
- Testing
You do not need to submit a complete solution to be considered for admission. However,
the more complete your solution, the better your chances of being accepted. Each
solution will be hollistically reviewed by a member of the Software Team.
##################################################
# Packet Format
##################################################
The packet format is the following:
+-------------+--------------+-------------------------------------------------------+
| Item | Size (bytes) | Description |
+-------------+--------------+-------------------------------------------------------+
| Start Bits | 2 | The start bits for every packet. Always 0x4744. |
| Identifier | 1 | The identifier of the packet. |
| Payload | Variable | The payload of the packet, varying based on the |
| | | identifier received. |
| Checksum | 1 | The BSD checksum of the packet. |
+-------------+--------------+-------------------------------------------------------+
Each packet will begin with a 1 byte identifier. This identifier will be used to
determine the layout of the rest of the packet and how to handle the packet.
| Identifier | Message |
|------------|--------------------|
| 0x00 | ACK |
| 0x01 | NACK |
| 0x02 | Get Kill Status |
| 0x03 | Return Kill Status |
| 0x04 | Heart Beat |
| 0x05 | Kill |
| 0x06 | Unkill |
| 0x07 | Set Thrust |
At the end of every packet is a 1 byte checksum of all the data in the packet
to verify packet integrity. It is calculated by taking the BSD checksum of the
entire packet minus the checksum byte. You will need to implement the BSD checksum
in the language of your choice. Keep the length of the checksum to just one byte,
ie, if your calculated checksum is more than one byte, take the least significant
byte. The formula found on the algorithm's Wikipedia page is sufficient, just remember
to limit your checksum to one byte (8 bits).
After the packet identifier, the contents of the packet become specific to the
message type sent.
| Identifier | Payload Size | Payload |
|------------|--------------|---------|
| 0x00 | 0 | None |
| 0x01 | 0 | None |
| 0x02 | 0 | None |
| 0x03 | 1 | 0x00 if kill is disabled, 0x01 if kill is enabled |
| 0x04 | 0 | None |
| 0x05 | 0 | None |
| 0x06 | 0 | None |
| 0x07 | 5 | 1 byte thruster ID, 4 bytes float thrust value in little endian |
##################################################
# Expected Behavior
##################################################
## ACK and NACK
ACK and NACK packets are general acknowledged and not acknowledged packets. They
are sent back to the sender of the packet to indicate that the packet was received
and processed. The ACK packet is sent back if the packet was processed successfully
and the NACK packet is sent back if the packet was not processed successfully (ie,
an error occurred, the checksum was invalid, etc.).
Your driver is not expected to send ACK or NACK packets. If these packets are sent
to your driver, it should return a NACK packet to indicate that the request was not
acknowledged.
## Kill System
Your driver will be able to set and unset the kill of your device. The kill system
is used for safety, and temporarily disables all functioning on the device.
Sending a KILL packet will result in the device being killed. Your driver should store
this as some sort of state value that it will hold onto. An ACK packet will be
returned if the kill is not currently set, and a NACK packet will be returned if the
kill is already set. Likewise, sending an UNKILL packet will result in the device
being un-killed. An ACK packet will be returned if the kill is currently set, and a
NACK packet will be returned if the kill is not currently set.
Sending a GET KILL STATUS packet will return the current kill status of the device
in the form of a RETURN KILL STATUS packet. If the kill is not currently set, the
RETURN KILL STATUS packet will have a payload of 0x00. If the kill is currently
set, the RETURN KILL STATUS packet will have a payload of 0x01.
If any thrusters are currently active, they should be disabled when the kill is set (ie,
set to 0). Upon unkill, the thrusters should be set back to their previous values.
## Thrust
Your driver will be able to set the thrust of the thrusters on your device. The
thrust is a float value between 0 and 1 that represents the percentage of the
maximum thrust that the thruster should be set to. The thrusters are identified
by an ID from 0 to 7.
Sending a SET THRUST packet will set the thrust of the thruster with the given ID
to the given thrust value. An ACK packet will be returned if the thruster ID is
valid and the thrust value is valid. A NACK packet will be returned if the thruster
ID is invalid or the thrust value is invalid.
If the kill is currently set, the thruster should not be set to the given value,
but the ACK packet should still be returned.
## Heartbeat
You must send a HEARTBEAT packet at least every 1 second to your device in order
for it to remain unkilled. If a HEARTBEAT packet is not sent at least every 1
second, the device immediately becomes killed. HEARTBEAT packets are not acknowledged.
## Incomplete Packets
The packet format is designed to be robust to incomplete packets. If a packet is
received that is not complete, the packet should be discarded and no response
should be sent. You know the length and expected format of each packet, if something
is invalid, you should discard the packet and not send a response.
##################################################
# Implementation and Testing
##################################################
You will be provided small starter scripts in both Python and C++ for you to work
with. Your application will not be preferred in any way for using either language.
The provided code is purposefully minimal so you have the freedom to implement
your solution however you want. However, please keep the basic interfaces we have
provided for you in either language so testing your solution is easier. Though your
solution will not just be graded for its correctness, it is an important factor.
You will be provided with a simple simulator that will send packets to your driver
and receive packets from your driver. You can use this simulator to test your
driver. The simulator will be provided in both Python and C++.
To run the Python file, use `python3 main.py`. To run the C++ file, use `./build.sh`
to build the executable, and then run `./bin/mil-test`.