pc_serial: add a termios member to store config across open cycles
This commit is contained in:
parent
ddee8aa960
commit
f71a01ad56
@ -50,6 +50,8 @@ SerialDevice::SerialDevice(const struct serial_support_descriptor *device,
|
||||
fDeviceThread(-1),
|
||||
fStopDeviceThread(false)
|
||||
{
|
||||
memset(&fTTYConfig, 0, sizeof(termios));
|
||||
fTTYConfig.c_cflag = B9600 | CS8 | CREAD;
|
||||
memset(fReadBuffer, 'z', DEF_BUFFER_SIZE);
|
||||
memset(fWriteBuffer, 'z', DEF_BUFFER_SIZE);
|
||||
}
|
||||
@ -103,6 +105,21 @@ SerialDevice::SetModes(struct termios *tios)
|
||||
if (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;
|
||||
uint16 divisor = SupportDescriptor()->bauds[baudIndex];
|
||||
|
||||
@ -529,6 +546,10 @@ SerialDevice::Open(uint32 flags)
|
||||
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
|
||||
fDeviceThread = spawn_kernel_thread(_DeviceThread, "usb_serial device thread",
|
||||
B_NORMAL_PRIORITY, this);
|
||||
|
@ -150,6 +150,7 @@ static void InterruptCallbackFunction(void *cookie,
|
||||
struct tty * fSlaveTTY;
|
||||
struct tty_cookie * fSystemTTYCookie;
|
||||
struct tty_cookie * fDeviceTTYCookie;
|
||||
struct termios fTTYConfig;
|
||||
|
||||
/* device thread management */
|
||||
thread_id fDeviceThread;
|
||||
|
Loading…
x
Reference in New Issue
Block a user