Moved baud rate to serial device struct and fixed log message
This commit is contained in:
parent
e1b71850bb
commit
2446fc9af2
|
|
@ -42,7 +42,7 @@ int arduino_update(SerialDevice* serialdevice, void* data, size_t size)
|
||||||
// return result;
|
// return result;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
int arduino_init(SerialDevice* serialdevice, const char* portdev, int baud)
|
int arduino_init(SerialDevice* serialdevice, const char* portdev)
|
||||||
{
|
{
|
||||||
slogi("initializing arduino serial device...");
|
slogi("initializing arduino serial device...");
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
@ -58,8 +58,8 @@ int arduino_init(SerialDevice* serialdevice, const char* portdev, int baud)
|
||||||
slogd("Opening port.\n");
|
slogd("Opening port.\n");
|
||||||
check(sp_open(serialdevice->port, SP_MODE_READ_WRITE));
|
check(sp_open(serialdevice->port, SP_MODE_READ_WRITE));
|
||||||
|
|
||||||
slogd("Setting port to 9600 8N1, no flow control.\n");
|
slogd("Setting port to %i 8N1, no flow control", serialdevice->baud);
|
||||||
check(sp_set_baudrate(serialdevice->port, baud));
|
check(sp_set_baudrate(serialdevice->port, serialdevice->baud));
|
||||||
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));
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
|
|
||||||
int arduino_update(SerialDevice* serialdevice, void* data, size_t size);
|
int arduino_update(SerialDevice* serialdevice, void* data, size_t size);
|
||||||
int arduino_init(SerialDevice* serialdevice, const char* portdev, int baud);
|
int arduino_init(SerialDevice* serialdevice, const char* portdev);
|
||||||
int arduino_free(SerialDevice* serialdevice);
|
int arduino_free(SerialDevice* serialdevice);
|
||||||
int check(enum sp_return result);
|
int check(enum sp_return result);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,9 @@ int serialdev_init(SerialDevice* serialdevice, const char* portdev, int motorspo
|
||||||
|
|
||||||
serialdevice->motorsposition = motorsposition;
|
serialdevice->motorsposition = motorsposition;
|
||||||
|
|
||||||
error = arduino_init(serialdevice, portdev, baud);
|
serialdevice->baud = baud;
|
||||||
|
|
||||||
|
error = arduino_init(serialdevice, portdev);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ 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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue