Fix issue not setting correct baud rate through to libserialport

This commit is contained in:
Paul Dino Jones 2024-09-30 22:21:35 -04:00
parent 32a15eff50
commit 558b298a78
3 changed files with 13 additions and 13 deletions

View File

@ -48,18 +48,18 @@ int arduino_init(SerialDevice* serialdevice, const char* portdev)
int error = 0; int error = 0;
char* port_name = strdup(portdev); char* port_name = strdup(portdev);
slogd("Looking for port %s.\n", port_name); slogd("Looking for port %s", port_name);
error = check(sp_get_port_by_name(port_name, &serialdevice->port)); error = check(sp_get_port_by_name(port_name, &serialdevice->port));
if (error != 0) if (error != 0)
{ {
return error; return error;
} }
slogd("Opening port.\n"); slogd("Opening port");
check(sp_open(serialdevice->port, SP_MODE_READ_WRITE)); check(sp_open(serialdevice->port, SP_MODE_READ_WRITE));
slogd("Setting port to %i 8N1, no flow control", serialdevice->baud); slogd("Setting port to %i 8N1, no flow control", serialdevice->baudrate);
check(sp_set_baudrate(serialdevice->port, serialdevice->baud)); check(sp_set_baudrate(serialdevice->port, serialdevice->baudrate));
check(sp_set_bits(serialdevice->port, 8)); check(sp_set_bits(serialdevice->port, 8));
check(sp_set_parity(serialdevice->port, SP_PARITY_NONE)); check(sp_set_parity(serialdevice->port, SP_PARITY_NONE));
check(sp_set_stopbits(serialdevice->port, 1)); check(sp_set_stopbits(serialdevice->port, 1));

View File

@ -133,7 +133,7 @@ int serialdev_free(SimDevice* this)
int serialdev_init(SerialDevice* serialdevice, DeviceSettings* ds) int serialdev_init(SerialDevice* serialdevice, DeviceSettings* ds)
{ {
slogi("initializing serial device on port %s...", ds->serialdevsettings.portdev); slogi("initializing serial device on port %s to %i...", ds->serialdevsettings.portdev, ds->serialdevsettings.baud);
int error = 0; int error = 0;
@ -142,15 +142,16 @@ int serialdev_init(SerialDevice* serialdevice, DeviceSettings* ds)
switch (serialdevice->type) switch (serialdevice->type)
{ {
case SERIALDEV_WHEEL: case SERIALDEV_WHEEL:
// the wheel stuff assumed it was a usb // the wheel stuff assumed it was a usb
//error = wheeldev_init(&serialdevice->u.wheeldevice, ds); //error = wheeldev_init(&serialdevice->u.wheeldevice, ds);
error = moza_init(serialdevice, ds->serialdevsettings.portdev); error = moza_init(serialdevice, ds->serialdevsettings.portdev);
break; break;
default: default:
error = arduino_init(serialdevice, ds->serialdevsettings.portdev ); error = arduino_init(serialdevice, ds->serialdevsettings.portdev );
break;
} }

View File

@ -48,7 +48,6 @@ typedef struct
int id; int id;
SerialType type; SerialType type;
struct sp_port* port; struct sp_port* port;
int baud;
SerialDeviceType devicetype; SerialDeviceType devicetype;
// move these two they only apply to the haptic device // move these two they only apply to the haptic device
int motorsposition; int motorsposition;