pc_serial: add a termios member to store config across open cycles
This commit is contained in:
@@ -50,6 +50,8 @@ SerialDevice::SerialDevice(const struct serial_support_descriptor *device,
|
|||||||
fDeviceThread(-1),
|
fDeviceThread(-1),
|
||||||
fStopDeviceThread(false)
|
fStopDeviceThread(false)
|
||||||
{
|
{
|
||||||
|
memset(&fTTYConfig, 0, sizeof(termios));
|
||||||
|
fTTYConfig.c_cflag = B9600 | CS8 | CREAD;
|
||||||
memset(fReadBuffer, 'z', DEF_BUFFER_SIZE);
|
memset(fReadBuffer, 'z', DEF_BUFFER_SIZE);
|
||||||
memset(fWriteBuffer, 'z', DEF_BUFFER_SIZE);
|
memset(fWriteBuffer, 'z', DEF_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
@@ -103,6 +105,21 @@ SerialDevice::SetModes(struct termios *tios)
|
|||||||
if (baudIndex > BLAST)
|
if (baudIndex > BLAST)
|
||||||
baudIndex = BLAST;
|
baudIndex = BLAST;
|
||||||
|
|
||||||
|
// update our master config in full
|
||||||
|
memcpy(&fTTYConfig, tios, sizeof(termios));
|
||||||
|
fTTYConfig.c_cflag &= ~CBAUD;
|
||||||
|
fTTYConfig.c_cflag |= baudIndex;
|
||||||
|
|
||||||
|
// only apply the relevant parts to the device side
|
||||||
|
termios config;
|
||||||
|
memset(&config, 0, sizeof(termios));
|
||||||
|
config.c_cflag = tios->c_cflag;
|
||||||
|
config.c_cflag &= ~CBAUD;
|
||||||
|
config.c_cflag |= baudIndex;
|
||||||
|
|
||||||
|
// update the termios of the device side
|
||||||
|
gTTYModule->tty_control(fDeviceTTYCookie, TCSETA, &config, sizeof(termios));
|
||||||
|
|
||||||
uint8 lcr = 0;
|
uint8 lcr = 0;
|
||||||
uint16 divisor = SupportDescriptor()->bauds[baudIndex];
|
uint16 divisor = SupportDescriptor()->bauds[baudIndex];
|
||||||
|
|
||||||
@@ -529,6 +546,10 @@ SerialDevice::Open(uint32 flags)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set our config (will propagate to the slave config as well in SetModes()
|
||||||
|
gTTYModule->tty_control(fSystemTTYCookie, TCSETA, &fTTYConfig,
|
||||||
|
sizeof(termios));
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
fDeviceThread = spawn_kernel_thread(_DeviceThread, "usb_serial device thread",
|
fDeviceThread = spawn_kernel_thread(_DeviceThread, "usb_serial device thread",
|
||||||
B_NORMAL_PRIORITY, this);
|
B_NORMAL_PRIORITY, this);
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ static void InterruptCallbackFunction(void *cookie,
|
|||||||
struct tty * fSlaveTTY;
|
struct tty * fSlaveTTY;
|
||||||
struct tty_cookie * fSystemTTYCookie;
|
struct tty_cookie * fSystemTTYCookie;
|
||||||
struct tty_cookie * fDeviceTTYCookie;
|
struct tty_cookie * fDeviceTTYCookie;
|
||||||
|
struct termios fTTYConfig;
|
||||||
|
|
||||||
/* device thread management */
|
/* device thread management */
|
||||||
thread_id fDeviceThread;
|
thread_id fDeviceThread;
|
||||||
|
|||||||
Reference in New Issue
Block a user