7 kyu
Compose protocol packet
86 of 131AlexPuts
Description:
There is a spaceship waiting on launchpad. In order to fuel it you are assigned to do some work.
Your task is to compose simple packet for a protocol.
In other words you should populate a byte array with data in order determined by a specification.
Fields:
Start flag | ID number | State | Scenario mask | Volume | Status | End flag | CRC |
---|---|---|---|---|---|---|---|
1 byte | 4 bytes | 2 bytes | 12 bytes | 6 bytes | 4 bytes | 1 byte | 1 byte |
HEX | HEX ASCII | HEX ASCII | HEX ASCII | DEC ASCII | HEX ASCII | HEX | HEX |
0x2 | "0000"..."FFFF" | "00"..."7F" | "000000000000"..."FFFFFFFFFFFF" | "000000"..."999999" | "00FF"..."FFFF" | 0x3 | 0..FF |
Flag fields used to identify start and end of message are constant:
Start flag = 0x2
End flag = 0x3
Function return value is:
Success : 1
Failure : -1
Function should return failure (-1) if data was out of range specified in table.
If function returns failure (-1) no data should be written to the passed pointer.
Note:
CRC is calculated only considering data between Start and End flags.
To calculate CRC you should use provided function (already implemented):
unsigned char crc8(const unsigned char *pc_block, unsigned int len);
/*
const unsigned char *pc_block - const pointer at the beginning of array crc is calculated for.
unsigned int len - amount of bytes to calculate crc for, starting from pc_block pointer.
*/
Arrays
Fundamentals
Similar Kata:
Stats:
Created | May 9, 2018 |
Published | May 12, 2018 |
Warriors Trained | 487 |
Total Skips | 54 |
Total Code Submissions | 1092 |
Total Times Completed | 131 |
C Completions | 86 |
C++ Completions | 50 |
Total Stars | 19 |
% of votes with a positive feedback rating | 80% of 41 |
Total "Very Satisfied" Votes | 28 |
Total "Somewhat Satisfied" Votes | 10 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 3 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 7 kyu |