Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/img_packet_spec #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sl1g18
Copy link

@sl1g18 sl1g18 commented Jan 31, 2019

I had no way of testing this, so hopefully it works alright.

The image payload is assumed to be located between the end of the 'number of fragments' and the last 144 bits of the packet, which are supposed to be the Hash/CRC bits.
The maximum payload size of the image packet is 602 bits, which amounts to 75 bytes + 2 extra bits, hence the 76 bytes size change.
uint32_t num_bytes = fragment_len/8;
uint8_t num_bits = fragment_len%8;
for(int i=0; i<num_bytes; i++) { image_data[i] = static_cast<char>b.get(8); }
image_data[num_bytes] = static_cast<char>b.get(num_bits);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has some spaces in its indentation

char image_data[6] = { 'i', 'm', 'a', 'g', 'e', '\0' };
std::copy(image_data, image_data+6, i.image_data);
char image_data[76];
uint64_t fragment_len = b.len()-(b.pos()+144);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be get_len and get_pos

uint32_t num_bytes = fragment_len/8;
uint8_t num_bits = fragment_len%8;
for(int i=0; i<num_bytes; i++) { image_data[i] = static_cast<char>b.get(8); }
image_data[num_bytes] = static_cast<char>b.get(num_bits);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be parens around b.get(num_bits)

uint64_t fragment_len = b.len()-(b.pos()+144);
uint32_t num_bytes = fragment_len/8;
uint8_t num_bits = fragment_len%8;
for(int i=0; i<num_bytes; i++) { image_data[i] = static_cast<char>b.get(8); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be parens around b.get(8)

char image_data[6] = { 'i', 'm', 'a', 'g', 'e', '\0' };
std::copy(image_data, image_data+6, i.image_data);
char image_data[76];
uint64_t fragment_len = b.len()-(b.pos()+144);
Copy link
Member

@charlie-wt charlie-wt Feb 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b.get_len() is in bytes, whereas b.get_pos() is in bits (I appreciate that's pretty weird, and it might be nice to change the length to be in bits too)... however, if I try (b.get_len() * 8) - (b.get_pos() + 144) I get back 2656 bits, which is 332 bytes. I appreciate that I could be wrong about the size (I've only got the Excel spreadsheet to go off and I've had to guess intent a couple of times), and if I change the declared length of image_data from 76 to 332 with the other fixes it seems to work (or at least it spits out some json), so I'll sort of leave it up to you on how to proceed, as long as it all works in the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants