diff --git a/include/rdcu_rmap.h b/include/rdcu_rmap.h index b0cdc84fd1692d3d179563e9ccf03095db35b4de..a9acb41e019fb812727f2e092c00483bd5a194f0 100644 --- a/include/rdcu_rmap.h +++ b/include/rdcu_rmap.h @@ -49,13 +49,13 @@ int rdcu_set_destination_path(uint8_t *path, uint8_t len); int rdcu_set_return_path(uint8_t *path, uint8_t len); void rdcu_set_source_logical_address(uint8_t addr); void rdcu_set_destination_key(uint8_t key); -size_t rdcu_get_data_mtu(void); +uint32_t rdcu_get_data_mtu(void); int rdcu_rmap_sync_status(void); void rdcu_rmap_reset_log(void); -int rdcu_rmap_init(size_t mtu, +int rdcu_rmap_init(uint32_t mtu, int32_t (*tx)(const void *hdr, uint32_t hdr_size, const uint8_t non_crc_bytes, const void *data, uint32_t data_size), diff --git a/lib/rdcu_pkt_to_file.c b/lib/rdcu_pkt_to_file.c index 80da5b2442783ef6c4ca6011108ae42b8f7232ff..db4843fa3aaa20d2186ea89859f637265dd315c4 100644 --- a/lib/rdcu_pkt_to_file.c +++ b/lib/rdcu_pkt_to_file.c @@ -211,7 +211,7 @@ static uint32_t rmap_rx_dummy(uint8_t *pkt) */ static int read_rdcu_pkt_mode_cfg(uint8_t *icu_addr, uint8_t *rdcu_addr, - unsigned long *mtu) + uint32_t *mtu) { /* TODO: Build string" %s/.rdcu_pkt_mode_cfg", RDCU_PKT_MODE_DIR */ char line[256]; @@ -224,7 +224,7 @@ static int read_rdcu_pkt_mode_cfg(uint8_t *icu_addr, uint8_t *rdcu_addr, if (fp == NULL) { /* use default values */ - printf("Use ICU_ADDR = %#02X, RDCU_ADDR = %#02X and MTU = %lu for the RAMP packets.\n", *icu_addr, *rdcu_addr, *mtu); + printf("Use ICU_ADDR = %#02X, RDCU_ADDR = %#02X and MTU = %u for the RAMP packets.\n", *icu_addr, *rdcu_addr, *mtu); return 0; } @@ -274,19 +274,19 @@ static int read_rdcu_pkt_mode_cfg(uint8_t *icu_addr, uint8_t *rdcu_addr, end = NULL; errno = 0; i = strtoul(line + l, &end, 0); - if (end == line + l || errno == ERANGE || i > INT_MAX) { + if (end == line + l || errno == ERANGE || i > INT32_MAX) { fprintf(stderr, "Error reading MTU.\n"); errno = 0; fclose(fp); return -1; } - *mtu = i; + *mtu = (uint32_t)i; continue; } } fclose(fp); - printf("Use ICU_ADDR = %#02X, RDCU_ADDR = %#02X and MTU = %lu for the RAMP packets.\n", *icu_addr, *rdcu_addr, *mtu); + printf("Use ICU_ADDR = %#02X, RDCU_ADDR = %#02X and MTU = %u for the RAMP packets.\n", *icu_addr, *rdcu_addr, *mtu); return 0; } @@ -304,7 +304,7 @@ static int read_rdcu_pkt_mode_cfg(uint8_t *icu_addr, uint8_t *rdcu_addr, int init_rmap_pkt_to_file(void) { uint8_t icu_addr, rdcu_addr; - unsigned long mtu; + uint32_t mtu; if (read_rdcu_pkt_mode_cfg(&icu_addr, &rdcu_addr, &mtu)) return -1; diff --git a/lib/rdcu_rmap.c b/lib/rdcu_rmap.c index 0e14b775f9dace881025ee7e7a51d85095d825d8..766070ab72e29839daa53b356f44162e57a38079 100644 --- a/lib/rdcu_rmap.c +++ b/lib/rdcu_rmap.c @@ -91,7 +91,7 @@ static int32_t (*rmap_tx)(const void *hdr, uint32_t hdr_size, const void *data, uint32_t data_size); static uint32_t (*rmap_rx)(uint8_t *pkt); -static size_t data_mtu; /* maximum data transfer size per unit */ +static uint32_t data_mtu; /* maximum data transfer size per unit */ @@ -745,7 +745,7 @@ void rdcu_set_destination_key(uint8_t key) * @returns the mtu */ -size_t rdcu_get_data_mtu(void) +uint32_t rdcu_get_data_mtu(void) { return data_mtu; } @@ -791,7 +791,7 @@ void rdcu_rmap_reset_log(void) * @returns 0 on success, otherwise error */ -int rdcu_rmap_init(size_t mtu, +int rdcu_rmap_init(uint32_t mtu, int32_t (*tx)(const void *hdr, uint32_t hdr_size, const uint8_t non_crc_bytes, const void *data, uint32_t data_size),