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: Wed, 21 Oct 2009 10:43:36 +0200 [thread overview]
Message-ID: <4ADEC9B8.2050701@gmail.com> (raw)
In-Reply-To: <200910201036.03028.denkenz@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1013 bytes --]
Hello,
I have attached a small patch which allows gattty.c to enable/disable
the read functionality on the serial port.
Cheers,
Ryan
Denis Kenzior wrote:
> Hi Ryan,
>
>>> You're blowing away the result of cfmakeraw. Most of the devices are not
>>> true serial devices and so do not need any of the special options.
>>> Passing a NULL options GHashTable should result in cfmakeraw. Why don't
>>> you just pass all the options you need instead of using tcgetattr?
>> Should i just move the tcgetattr() to happen before cfmakeraw()?
>
> Only one (executed last) will have effect, and I want it to be the cfmakeraw.
> So simply get rid of tcgetattr.
>
>>> The other parts of the patch look good to me.
>> Ok. Why don't i just add the string options ("read", others...) in
>> gattty.c?
>
> This is what I would prefer.
>
> Regards,
> -Denis
> _______________________________________________
> 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: 861 bytes --]
diff --git a/gatchat/gattty.c b/gatchat/gattty.c
index 63d26d4..f18eca4 100644
--- a/gatchat/gattty.c
+++ b/gatchat/gattty.c
@@ -97,6 +97,18 @@ static gboolean set_baud(const char *baud, struct termios *ti)
return TRUE;
}
+static gboolean set_read(const char *bits, struct termios *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"))
@@ -210,6 +222,8 @@ 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;
next prev parent reply other threads:[~2009-10-21 8: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
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 [this message]
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=4ADEC9B8.2050701@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox