mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
system/irtest: Fix issues regarding portability and buffer size
This commit fixes issues regarding portability by using variables with fixed width (and their format macro constants). Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
This commit is contained in:
parent
901278a4ba
commit
6cb1a04fe7
2 changed files with 10 additions and 9 deletions
|
|
@ -32,7 +32,7 @@ config SYSTEM_IRTEST_MAX_NIRDEV
|
|||
default 2
|
||||
|
||||
config SYSTEM_IRTEST_MAX_SIRDATA
|
||||
int "The Maximum size of sending data in unsigned int"
|
||||
int "The Maximum size of sending data in nwords (4 bytes)"
|
||||
default 64
|
||||
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -226,7 +226,8 @@ CMD1(close_device, size_t, index)
|
|||
|
||||
CMD1(write_data, size_t, index)
|
||||
{
|
||||
unsigned int data[CONFIG_SYSTEM_IRTEST_MAX_SIRDATA];
|
||||
uint32_t data[CONFIG_SYSTEM_IRTEST_MAX_SIRDATA];
|
||||
uint32_t tmp;
|
||||
|
||||
if (index >= CONFIG_SYSTEM_IRTEST_MAX_NIRDEV)
|
||||
{
|
||||
|
|
@ -236,7 +237,7 @@ CMD1(write_data, size_t, index)
|
|||
int size = 0;
|
||||
for (; size < CONFIG_SYSTEM_IRTEST_MAX_SIRDATA; size++)
|
||||
{
|
||||
unsigned int tmp = get_next_arg < unsigned int > ();
|
||||
tmp = get_next_arg < uint32_t > ();
|
||||
if (tmp == 0)
|
||||
{
|
||||
break;
|
||||
|
|
@ -250,14 +251,14 @@ CMD1(write_data, size_t, index)
|
|||
if (size % 2 == 0)
|
||||
{
|
||||
int result = write(g_irdevs[index], data,
|
||||
sizeof(unsigned int) * (size - 1));
|
||||
sizeof(uint32_t) * (size - 1));
|
||||
usleep(data[size - 1]);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return write(g_irdevs[index], data,
|
||||
sizeof(unsigned int) * size);
|
||||
sizeof(uint32_t) * size);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -268,20 +269,20 @@ CMD2(read_data, size_t, index, size_t, size)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
unsigned int data[size];
|
||||
uint32_t data[size];
|
||||
int result = read(g_irdevs[index], data, sizeof(data));
|
||||
if (result > 0)
|
||||
{
|
||||
result /= sizeof(unsigned int);
|
||||
result /= sizeof(uint32_t);
|
||||
for (int i = 0; i < result; i++)
|
||||
{
|
||||
if (i + 1 == result)
|
||||
{
|
||||
printf("%d\n", data[i]);
|
||||
printf("%" PRIu32 "\n", data[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%d, ", data[i]);
|
||||
printf("%" PRIu32 ", ", data[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue