windows: implement a dynamicly construct list of serial ports (Thanks to Edwin Evans)
This commit is contained in:
parent
2c37571a40
commit
8ed870d886
1 changed files with 9 additions and 5 deletions
|
@ -87,7 +87,6 @@ uart_close (const serial_port sp)
|
||||||
free (sp);
|
free (sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Remove PN53x related timeout
|
|
||||||
void
|
void
|
||||||
uart_set_speed (serial_port sp, const uint32_t uiPortSpeed)
|
uart_set_speed (serial_port sp, const uint32_t uiPortSpeed)
|
||||||
{
|
{
|
||||||
|
@ -111,7 +110,6 @@ uart_set_speed (serial_port sp, const uint32_t uiPortSpeed)
|
||||||
spw = (serial_port_windows *) sp;
|
spw = (serial_port_windows *) sp;
|
||||||
|
|
||||||
// Set timeouts
|
// Set timeouts
|
||||||
//printf ("UART_SPEED_T0_TIME (%d) = %d\n", uiPortSpeed, UART_SPEED_T0_TIME(uiPortSpeed));
|
|
||||||
int iTimeout = 200;
|
int iTimeout = 200;
|
||||||
spw->ct.ReadIntervalTimeout = 2;
|
spw->ct.ReadIntervalTimeout = 2;
|
||||||
spw->ct.ReadTotalTimeoutMultiplier = 0;
|
spw->ct.ReadTotalTimeoutMultiplier = 0;
|
||||||
|
@ -168,13 +166,19 @@ uart_send (serial_port sp, const byte_t * pbtTx, const size_t szTx)
|
||||||
|
|
||||||
// Path to the serial port is OS-dependant.
|
// Path to the serial port is OS-dependant.
|
||||||
// Try to guess what we should use.
|
// Try to guess what we should use.
|
||||||
#define DEFAULT_SERIAL_PORTS { "COM1", "COM2", "COM3", "COM4", NULL }
|
#define NUM_SERIAL_PORTS 8
|
||||||
char **
|
char **
|
||||||
uart_list_ports (void)
|
uart_list_ports (void)
|
||||||
{
|
{
|
||||||
// TODO: Wrote an automatic detection of Windows serial ports
|
// TODO: Wrote an automatic detection of Windows serial ports
|
||||||
|
|
||||||
// FIXME: Construct an dynamic allocated array of char* that contains default serial ports.
|
char ** availablePorts = malloc((1 + NUM_SERIAL_PORTS) * sizeof(char*));
|
||||||
const char ** availablePorts = DEFAULT_SERIAL_PORTS;
|
int i;
|
||||||
|
for (i = 0; i < NUM_SERIAL_PORTS; i++) {
|
||||||
|
availablePorts[i] = (char*)malloc(10);
|
||||||
|
sprintf(availablePorts[i], "COM%d", i+1);
|
||||||
|
}
|
||||||
|
availablePorts[i] = NULL;
|
||||||
|
|
||||||
return availablePorts;
|
return availablePorts;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue