From: Ryan Raasch <ryan.raasch@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH] When setting the serial port, the previous settings need to be preserved.
Date: Tue, 20 Oct 2009 09:43:01 +0200 [thread overview]
Message-ID: <4ADD6A05.8060301@gmail.com> (raw)
In-Reply-To: <200910191232.45844.denkenz@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 997 bytes --]
Denis Kenzior wrote:
> Hi Ryan,
>
>> This took a while to locate. Shouldn't it be possible to use stty
>> outside the daemon, and then daemon would just continue as usual?
>>
>> In my case, the cread was being removed, so no input data could be read.
>
> Sorry but the patch is wrong, since you're blowing away all options that have
> been set via the GHashTable.
Yea. Sorry. Put it in the wrong place, uggh. It should go before setting
the options, since the switches are or'ing and xor'ing.
>
> GAtTty is really a convenience method, if you need something specific, pass the
> option in the GHashTable or setup the fd however you wish by yourself.
>
> Regards,
> -Denis
But, there is a problem with the opening of the serial port b/c the
CREAD flag is destroyed if it is active, making the serial port unreadable.
Ryan
> _______________________________________________
> ofono mailing list
> ofono(a)ofono.org
> http://lists.ofono.org/listinfo/ofono
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: serial_port_enable_CREAD.patch --]
[-- Type: text/x-patch, Size: 1410 bytes --]
gatchat/gattty.c | 26 +++++++++++++++++++++-----
1 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/gatchat/gattty.c b/gatchat/gattty.c
index ed0fadf..aa9d3a4 100644
--- a/gatchat/gattty.c
+++ b/gatchat/gattty.c
@@ -97,6 +97,19 @@ static gboolean set_baud(const char *baud, struct termios *ti)
return TRUE;
}
+static gboolean set_read(value, &ti)
+{
+ if (g_str_equal(bits, "off"))
+ ti->c_cflag &= ~(CREAD);
+ else if (g_str_equal(bits, "on"))
+ ti->c_cflag |= CREAD;
+ else
+ return FALSE;
+
+ return TRUE;
+
+}
+
static gboolean set_stop_bits(const char *bits, struct termios *ti)
{
if (g_str_equal(bits, "1"))
@@ -186,6 +199,12 @@ static int open_device(const char *tty, GHashTable *options)
memset(&ti, 0, sizeof(ti));
cfmakeraw(&ti);
+ fd = open(tty, O_RDWR | O_NOCTTY | O_NONBLOCK);
+ if (fd < 0)
+ return -1;
+
+ tcgetattr(fd,&ti);
+
if (options) {
GHashTableIter iter;
const char *key;
@@ -210,17 +229,14 @@ static int open_device(const char *tty, GHashTable *options)
ok = set_rtscts(value, &ti);
else if (g_str_equal(key, "local"))
ok = set_local(value, &ti);
+ else if (g_str_equal(key, "read"))
+ ok = set_read(value, &ti);
if (ok == FALSE)
return -1;
}
}
- fd = open(tty, O_RDWR | O_NOCTTY | O_NONBLOCK);
- if (fd < 0)
- return -1;
-
- tcgetattr(fd,&ti);
tcflush(fd, TCIOFLUSH);
tcsetattr(fd, TCSANOW, &ti);
next prev parent reply other threads:[~2009-10-20 7:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-19 14:28 [PATCH] When setting the serial port, the previous settings need to be preserved Ryan Raasch
2009-10-19 17:32 ` Denis Kenzior
2009-10-20 7:43 ` Ryan Raasch [this message]
2009-10-20 9:10 ` Ryan Raasch
2009-10-20 15:13 ` Denis Kenzior
2009-10-20 15:51 ` Ryan Raasch
2009-10-20 15:36 ` Denis Kenzior
2009-10-21 8:43 ` Ryan Raasch
2009-10-22 0:09 ` Denis Kenzior
-- strict thread matches above, loose matches on Subject: below --
2009-10-19 17:18 Ryan Raasch
2009-10-19 17:21 ` Ryan Raasch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4ADD6A05.8060301@gmail.com \
--to=ryan.raasch@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.