Bidir optical comms working
This commit is contained in:
parent
822c8a21d7
commit
2967dcee39
2 changed files with 7 additions and 5 deletions
|
|
@ -73,18 +73,20 @@ int main(void) {
|
|||
int i = 0;
|
||||
while (23) {
|
||||
if (tx_st.remaining_bytes == 0) {
|
||||
if (i > 10000) {
|
||||
if (i > 1000) {
|
||||
res_buf.req_seq = req_seq;
|
||||
res_buf.res_seq = res_seq;
|
||||
res_seq += 1;
|
||||
//packetize(&res_buf, &res_buf.trailer);
|
||||
packetize(&res_buf, &res_buf.trailer);
|
||||
tx_st.tx_char = tx_buf;
|
||||
//tx_st.remaining_bytes = cobs_encode((uint8_t *)&res_buf, sizeof(res_buf), tx_buf, sizeof(tx_buf));;
|
||||
tx_st.remaining_bytes = cobs_encode((uint8_t *)&res_buf, sizeof(res_buf), tx_buf, sizeof(tx_buf));;
|
||||
/*
|
||||
for (int k=0; k < 8; k++)
|
||||
tx_buf[k] = 255-k;
|
||||
for (int k=0; k < 8; k++)
|
||||
tx_buf[8+k] = (k + 1) % 8;
|
||||
tx_st.remaining_bytes = 16;
|
||||
*/
|
||||
i = 0;
|
||||
} else {
|
||||
i++;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ if __name__ == '__main__':
|
|||
if byte_count == 0:
|
||||
print(f'\033[38;5;244m{time.time() - start_time: 8.3f} \033[0m', end='')
|
||||
|
||||
col = '\033[91m' if c == 0 else ('\033[0m' if c == (lastc - 1) % 256 else '\033[92m')
|
||||
col = '\033[91m' if c == 0 else '\033[0m' # if c == (lastc - 1) % 256 else '\033[92m')
|
||||
print(f'{col}{c:02x}', end=' ')
|
||||
line += bytes([c])
|
||||
byte_count += 1
|
||||
|
|
@ -72,6 +72,6 @@ if __name__ == '__main__':
|
|||
data = struct.pack('<I', seq)
|
||||
#seq += 1
|
||||
#ser.write(bytes(list(range(255, -1, -1))))
|
||||
#ser.write(cobs.encode(data + struct.pack('<I', zlib.crc32(data))) + b'\0')
|
||||
ser.write(cobs.encode(data + struct.pack('<I', zlib.crc32(data))) + b'\0')
|
||||
last_tx = time.time()
|
||||
#time.sleep(0.01)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue