From c721dc756c69f76ab218b8a5bc3f333b65c423af Mon Sep 17 00:00:00 2001 From: PgSocks Date: Fri, 23 Dec 2022 16:44:34 -0600 Subject: [PATCH] Set SDK port back default removed seq_id bounds --- src/robomaster.c | 4 ++-- src/robomaster.h | 4 ---- src/robomastersh.c | 9 ++------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/robomaster.c b/src/robomaster.c index 1cdd75f..73f3eb0 100644 --- a/src/robomaster.c +++ b/src/robomaster.c @@ -11,7 +11,7 @@ struct Session* session_new(void* buffer, size_t size) { else session->buffer = buffer; session->size = 0; - session->seq = RM_SDK_FIRST_SEQ_ID; + session->seq = 0; session->max_size = size; // TODO: Make this configurable session->hostbyte = host2byte(DEFAULT_CLIENT_HOST, DEFAULT_CLIENT_INDEX); @@ -30,7 +30,7 @@ message_new(struct Session* session, uint8_t cmdset, uint8_t cmdid, size_t lengt memcpy((void*)message->body, body, length); length += sizeof(struct Header) + sizeof(struct Footer); session->size += length; - int16_t seq = ++session->seq; + int16_t seq = session->seq++; message->header.preamble = 0x55; message->header.length_l = length & 0xFF; diff --git a/src/robomaster.h b/src/robomaster.h index e1556f2..2089dd4 100644 --- a/src/robomaster.h +++ b/src/robomaster.h @@ -74,10 +74,6 @@ Session session_new(void* buffer, size_t size); size_t session_size(Session session); -// SEQ ID will loop around -static const int16_t RM_SDK_FIRST_SEQ_ID = 11239; -static const int16_t RM_SDK_LAST_SEQ_ID = 20000; - static const uint8_t CONNECTION_WIFI_AP = 0; static const uint8_t CONNECTION_WIFI_STA = 1; static const uint8_t CONNECTION_USB_RNDIS = 2; diff --git a/src/robomastersh.c b/src/robomastersh.c index 6968641..de279c3 100644 --- a/src/robomastersh.c +++ b/src/robomastersh.c @@ -16,8 +16,7 @@ int main(int argc, char* argv[]) req.connection = CONNECTION_WIFI_AP; req.protocol = 0; req.ip_address = 0; - //req.port = 10010; - req.port = 10242; + req.port = 10010; const Message msg = set_sdk_connection_req_new(session, &req); int sockfd = socket(AF_INET, SOCK_DGRAM, 0); @@ -43,14 +42,10 @@ int main(int argc, char* argv[]) // check footer crc uint16_t expected_crc16 = crc16(recvbuff, recvb - 2); - uint16_t actual_crc16 = ntohs(*(uint16_t*)(recvbuff + recvb - 2)); + uint16_t actual_crc16 = *(uint16_t*)(recvbuff + recvb - 2); if(actual_crc16 != expected_crc16) fprintf(stderr, "expected crc16 %d got %d", actual_crc16, expected_crc16); - // check hostbyte - if(resp->header.receiver != session->hostbyte) - fprintf(stderr, "expected receiver %d got %d", session->hostbyte, resp->header.receiver); - return 0; }