Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.embedded > #634 > unrolled thread
| Started by | Les Cargill <lcargill99@comcast.com> |
|---|---|
| First post | 2014-02-13 18:39 -0600 |
| Last post | 2014-02-14 13:13 +0000 |
| Articles | 15 — 5 participants |
Back to article view | Back to comp.os.linux.embedded
When 0x0d become 0x0a Les Cargill <lcargill99@comcast.com> - 2014-02-13 18:39 -0600
Re: When 0x0d become 0x0a Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-02-13 20:49 -0500
Re: When 0x0d become 0x0a Les Cargill <lcargill99@comcast.com> - 2014-02-14 00:27 -0600
Re: When 0x0d become 0x0a Grant Edwards <invalid@invalid.invalid> - 2014-02-14 04:06 +0000
Re: When 0x0d become 0x0a Les Cargill <lcargill99@comcast.com> - 2014-02-14 21:19 -0600
Re: When 0x0d become 0x0a Grant Edwards <invalid@invalid.invalid> - 2014-02-15 04:31 +0000
Re: When 0x0d become 0x0a Przemek Klosowski <przemek@tux.dot.org> - 2014-04-11 00:57 +0000
Re: When 0x0d become 0x0a Les Cargill <lcargill99@comcast.com> - 2014-04-12 16:40 -0500
Re: When 0x0d become 0x0a Les Cargill <lcargill99@comcast.com> - 2014-04-12 16:36 -0500
Re: When 0x0d become 0x0a Grant Edwards <invalid@invalid.invalid> - 2014-04-14 16:46 +0000
Re: When 0x0d become 0x0a Les Cargill <lcargill99@comcast.com> - 2014-04-14 12:48 -0500
Re: When 0x0d become 0x0a Grant Edwards <invalid@invalid.invalid> - 2014-04-14 18:56 +0000
Re: When 0x0d become 0x0a Les Cargill <lcargill99@comcast.com> - 2014-04-14 20:16 -0500
Re: When 0x0d become 0x0a Grant Edwards <invalid@invalid.invalid> - 2014-04-15 15:15 +0000
Re: When 0x0d become 0x0a David <no@spam.please> - 2014-02-14 13:13 +0000
| From | Les Cargill <lcargill99@comcast.com> |
|---|---|
| Date | 2014-02-13 18:39 -0600 |
| Subject | When 0x0d become 0x0a |
| Message-ID | <ldjodp$m47$1@dont-email.me> |
I'm porting some code from one Linux to another. It uses serial ports. As opened, the serial port converts 0x0d characters to 0x0a characters. I have done some googling to find which *opts() functions control setting the file referred to by the handle for the serial port to be a pure, binary file. I see the one that turns off this conversion, but I want all characters to be received completely untrammelled. I also need to use fopen()... fclose(), so ORed together last-argument things in open() are out. What's a good website that shows *all* the serial port options for Linux? -- Les Cargill
[toc] | [next] | [standalone]
| From | Lew Pitcher <lew.pitcher@digitalfreehold.ca> |
|---|---|
| Date | 2014-02-13 20:49 -0500 |
| Message-ID | <FCeLu.435026$_n7.384776@fx20.iad> |
| In reply to | #634 |
On Thursday 13 February 2014 19:39, in comp.os.linux.embedded, "Les Cargill" <lcargill99@comcast.com> wrote: > I'm porting some code from one Linux to another. It uses serial ports. > > As opened, the serial port converts 0x0d characters to 0x0a characters. > > I have done some googling to find which *opts() functions control > setting the file referred to by the handle for the serial port > to be a pure, binary file. I see the one that turns off this conversion, > but I want all characters to be received completely untrammelled. > > I also need to use fopen()... fclose(), so ORed together last-argument > things in open() are out. I'm afraid that if you need such tight control of the serial-port data, you are probably going to have to work with low-level file I/O, at least a bit. Specifically, you are going to need the fd of your FILE * file (use POSIX fileno(3) to retrieve), and either the termios(3) tcgetattr()/tcsetattr() calls, or the ioctl(2) tty calls. You want to change the line conditioning of your serial port from COOKED or CBREAK mode to RAW mode. > What's a good website that shows *all* the serial port options for Linux? Sorry, I can't help you there. I don't know of any website that shows all the serial port options for Linux. However, the tty_ioctl(4), ioctl(2), and termios(3) manpages should help you. HTH -- Lew Pitcher "In Skills, We Trust" PGP public key available upon request
[toc] | [prev] | [next] | [standalone]
| From | Les Cargill <lcargill99@comcast.com> |
|---|---|
| Date | 2014-02-14 00:27 -0600 |
| Message-ID | <ldkcqp$8lo$1@dont-email.me> |
| In reply to | #635 |
Lew Pitcher wrote: > On Thursday 13 February 2014 19:39, in comp.os.linux.embedded, "Les Cargill" > <lcargill99@comcast.com> wrote: > >> I'm porting some code from one Linux to another. It uses serial ports. >> >> As opened, the serial port converts 0x0d characters to 0x0a characters. >> >> I have done some googling to find which *opts() functions control >> setting the file referred to by the handle for the serial port >> to be a pure, binary file. I see the one that turns off this conversion, >> but I want all characters to be received completely untrammelled. >> >> I also need to use fopen()... fclose(), so ORed together last-argument >> things in open() are out. > > I'm afraid that if you need such tight control of the serial-port data, you > are probably going to have to work with low-level file I/O, at least a bit. > > Specifically, you are going to need the fd of your FILE * file Not a problem - familiar with fileno(); I should have said as much; there's some boilerplate stuff already in the code to set baud rate and all using a return from fileno(); I've just never done the full, comprehensive study of all the serial port options in Linux. I forget what it was that I ran into that forced the use of fopen() rather than open(). > (use POSIX > fileno(3) to retrieve), and either the termios(3) tcgetattr()/tcsetattr() > calls, or the ioctl(2) tty calls. You want to change the line conditioning > of your serial port from COOKED or CBREAK mode to RAW mode. > > >> What's a good website that shows *all* the serial port options for Linux? > > Sorry, I can't help you there. I don't know of any website that shows all > the serial port options for Linux. > > However, the tty_ioctl(4), ioctl(2), and termios(3) manpages should help > you. > Excellent - those are a good start. Thanks! > HTH > -- Les Cargill
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2014-02-14 04:06 +0000 |
| Message-ID | <ldk4ni$hi3$1@reader1.panix.com> |
| In reply to | #634 |
On 2014-02-14, Les Cargill <lcargill99@comcast.com> wrote: > I'm porting some code from one Linux to another. It uses serial ports. > > As opened, the serial port converts 0x0d characters to 0x0a characters. > > I have done some googling to find which *opts() functions I've no idea what "*opts() functions" mean. > control setting the file referred to by the handle for the serial > port to be a pure, binary file. I see the one that turns off this > conversion, but I want all characters to be received completely > untrammelled. http://www.cmrr.umn.edu/~strupp/serial.html > I also need to use fopen()... fclose(), so ORed together last-argument > things in open() are out. Whatever. -- Grant
[toc] | [prev] | [next] | [standalone]
| From | Les Cargill <lcargill99@comcast.com> |
|---|---|
| Date | 2014-02-14 21:19 -0600 |
| Message-ID | <ldmm5q$2gq$1@dont-email.me> |
| In reply to | #636 |
Grant Edwards wrote: > On 2014-02-14, Les Cargill <lcargill99@comcast.com> wrote: >> I'm porting some code from one Linux to another. It uses serial ports. >> >> As opened, the serial port converts 0x0d characters to 0x0a characters. >> >> I have done some googling to find which *opts() functions > > I've no idea what "*opts() functions" mean. > >> control setting the file referred to by the handle for the serial >> port to be a pure, binary file. I see the one that turns off this >> conversion, but I want all characters to be received completely >> untrammelled. > > http://www.cmrr.umn.edu/~strupp/serial.html > >> I also need to use fopen()... fclose(), so ORed together last-argument >> things in open() are out. > > Whatever. > I said this because there is a bit you can OR into the last argument to open() that causes the LF/CR translation to stop. I can't use that. -- Les Cargill
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2014-02-15 04:31 +0000 |
| Message-ID | <ldmqij$qeb$1@reader1.panix.com> |
| In reply to | #639 |
On 2014-02-15, Les Cargill <lcargill99@comcast.com> wrote: > I said this because there is a bit you can OR into the last argument > to open() that causes the LF/CR translation to stop. I can't use > that. Huh? Can you point to code or documentation for that? I've been using serial ports on Linux for 20 years, I've written multiple tty and serial drivers for Linux, and I've spent a lot of time in general wandering around the the Linux serial subsystem. I've never heard of such a thing before. It's also not mentioned in the open() man page. The last parameter to open() controls a newly created file's mode bits (read/write/execute for user/group/other). That argument is ignored (and need not even be passed) when opening a file or device that already exists (as you are when opening a serial port). -- Grant
[toc] | [prev] | [next] | [standalone]
| From | Przemek Klosowski <przemek@tux.dot.org> |
|---|---|
| Date | 2014-04-11 00:57 +0000 |
| Message-ID | <li7elg$ctf$1@dont-email.me> |
| In reply to | #640 |
On Sat, 15 Feb 2014 04:31:16 +0000, Grant Edwards wrote: > On 2014-02-15, Les Cargill <lcargill99@comcast.com> wrote: > >> I said this because there is a bit you can OR into the last argument to >> open() that causes the LF/CR translation to stop. I can't use that. > > Huh? Can you point to code or documentation for that? > > I've been using serial ports on Linux for 20 years, I've written > multiple tty and serial drivers for Linux, and I've spent a lot of time > in general wandering around the the Linux serial subsystem. I've never > heard of such a thing before. Is it possible that Les remembers the Windows I/O routines which did indeed have a binary/ascii option that handled line endings?
[toc] | [prev] | [next] | [standalone]
| From | Les Cargill <lcargill99@comcast.com> |
|---|---|
| Date | 2014-04-12 16:40 -0500 |
| Message-ID | <licbi1$1bc$1@dont-email.me> |
| In reply to | #658 |
Przemek Klosowski wrote: > On Sat, 15 Feb 2014 04:31:16 +0000, Grant Edwards wrote: > >> On 2014-02-15, Les Cargill <lcargill99@comcast.com> wrote: >> >>> I said this because there is a bit you can OR into the last argument to >>> open() that causes the LF/CR translation to stop. I can't use that. >> >> Huh? Can you point to code or documentation for that? >> >> I've been using serial ports on Linux for 20 years, I've written >> multiple tty and serial drivers for Linux, and I've spent a lot of time >> in general wandering around the the Linux serial subsystem. I've never >> heard of such a thing before. > > Is it possible that Les remembers the Windows I/O routines which did > indeed have a binary/ascii option that handled line endings? > That would certainly explain it, although this happens to be on something identified as Linux. I'll try to clear this up later. It may be that the library in play ( this is a Tiny Linux ) mixes _fmode and open() semantics. Text vs.binary mode is a non-sequitur when it comes to Linux. -- Les Cargill
[toc] | [prev] | [next] | [standalone]
| From | Les Cargill <lcargill99@comcast.com> |
|---|---|
| Date | 2014-04-12 16:36 -0500 |
| Message-ID | <licbbb$vjm$1@dont-email.me> |
| In reply to | #640 |
Grant Edwards wrote: > On 2014-02-15, Les Cargill <lcargill99@comcast.com> wrote: > >> I said this because there is a bit you can OR into the last argument >> to open() that causes the LF/CR translation to stop. I can't use >> that. > > Huh? Can you point to code or documentation for that? > http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_075.htm This may be a local heresy specific to the system I am using. To be sure, this system's the first one I'd seen that does this. my habit is to use fopen() as a default ( because it seems more multiplatform than open() and I have to mix Windows and Linux a lot ) , so I probably have many less miles on open() than you do. The stack I am using may merge _fmode semantics in with open(). Seems kinda Windows-ish, though. http://stackoverflow.com/questions/2266992/no-o-binary-and-o-text-flags-in-linux > I've been using serial ports on Linux for 20 years, I've written > multiple tty and serial drivers for Linux, and I've spent a lot of > time in general wandering around the the Linux serial subsystem. I've > never heard of such a thing before. It's also not mentioned in the > open() man page. You are absolutely correct. I'll try to report back later. > The last parameter to open() controls a newly created > file's mode bits (read/write/execute for user/group/other). That > argument is ignored (and need not even be passed) when opening a file > or device that already exists (as you are when opening a serial port). > -- Les Cargill
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2014-04-14 16:46 +0000 |
| Message-ID | <lih3dq$a0$1@reader1.panix.com> |
| In reply to | #659 |
On 2014-04-12, Les Cargill <lcargill99@comcast.com> wrote:
> Grant Edwards wrote:
>> On 2014-02-15, Les Cargill <lcargill99@comcast.com> wrote:
>>
>>> I said this because there is a bit you can OR into the last argument
>>> to open() that causes the LF/CR translation to stop. I can't use
>>> that.
>>
>> Huh? Can you point to code or documentation for that?
>>
>
> http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_075.htm
>
> This may be a local heresy specific to the system I am using. To
> be sure, this system's the first one I'd seen that does
> this.
After a bit of Googling it appears it might be a Microsoftism. Google
also finds discussion of adding O_TEXT and O_BINARY flags to cygwin. I
don't know if it happened...
--
Grant Edwards grant.b.edwards Yow! LBJ, LBJ, how many
at JOKES did you tell today??!
gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Les Cargill <lcargill99@comcast.com> |
|---|---|
| Date | 2014-04-14 12:48 -0500 |
| Message-ID | <lih6ni$o39$1@dont-email.me> |
| In reply to | #661 |
Grant Edwards wrote: > On 2014-04-12, Les Cargill <lcargill99@comcast.com> wrote: >> Grant Edwards wrote: >>> On 2014-02-15, Les Cargill <lcargill99@comcast.com> wrote: >>> >>>> I said this because there is a bit you can OR into the last argument >>>> to open() that causes the LF/CR translation to stop. I can't use >>>> that. >>> >>> Huh? Can you point to code or documentation for that? >>> >> >> http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_075.htm >> >> This may be a local heresy specific to the system I am using. To >> be sure, this system's the first one I'd seen that does >> this. > > After a bit of Googling it appears it might be a Microsoftism. Definitively. I just suspect it may have bled over into nominally Linux systems. All goes back to "raw" and "cooked" mode in DOS, which originated there, SFAIK. Heresy! :) > Google > also finds discussion of adding O_TEXT and O_BINARY flags to cygwin. I > don't know if it happened... > -- Les Cargill
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2014-04-14 18:56 +0000 |
| Message-ID | <lihb0q$cf4$1@reader1.panix.com> |
| In reply to | #662 |
On 2014-04-14, Les Cargill <lcargill99@comcast.com> wrote:
> Grant Edwards wrote:
>> On 2014-04-12, Les Cargill <lcargill99@comcast.com> wrote:
>>> Grant Edwards wrote:
>>>> On 2014-02-15, Les Cargill <lcargill99@comcast.com> wrote:
>>>>
>>>>> I said this because there is a bit you can OR into the last argument
>>>>> to open() that causes the LF/CR translation to stop. I can't use
>>>>> that.
>>>>
>>>> Huh? Can you point to code or documentation for that?
>>>>
>>>
>>> http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_075.htm
>>>
>>> This may be a local heresy specific to the system I am using. To
>>> be sure, this system's the first one I'd seen that does
>>> this.
>>
>> After a bit of Googling it appears it might be a Microsoftism.
>
> Definitively. I just suspect it may have bled over into nominally
> Linux systems.
>
> All goes back to "raw" and "cooked" mode in DOS, which originated
> there, SFAIK.
No, raw and cooked mode is a Unix thing and predates DOS by a long
time. On Unix, tty devices (like serial ports) can be in raw or
canonical (AKA "cooked") mode. When in cooked mode, you can enable
things like conversion of cr->lf or vice versa, mapping
lowercase->uppercase, handling various control characters, xon/xoff
flow control, and so on.
--
Grant Edwards grant.b.edwards Yow! Do you think the
at "Monkees" should get gas on
gmail.com odd or even days?
[toc] | [prev] | [next] | [standalone]
| From | Les Cargill <lcargill99@comcast.com> |
|---|---|
| Date | 2014-04-14 20:16 -0500 |
| Message-ID | <lii10i$gbo$1@dont-email.me> |
| In reply to | #663 |
Grant Edwards wrote: > On 2014-04-14, Les Cargill <lcargill99@comcast.com> wrote: >> Grant Edwards wrote: >>> On 2014-04-12, Les Cargill <lcargill99@comcast.com> wrote: >>>> Grant Edwards wrote: >>>>> On 2014-02-15, Les Cargill <lcargill99@comcast.com> wrote: >>>>> >>>>>> I said this because there is a bit you can OR into the last argument >>>>>> to open() that causes the LF/CR translation to stop. I can't use >>>>>> that. >>>>> >>>>> Huh? Can you point to code or documentation for that? >>>>> >>>> >>>> http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_075.htm >>>> >>>> This may be a local heresy specific to the system I am using. To >>>> be sure, this system's the first one I'd seen that does >>>> this. >>> >>> After a bit of Googling it appears it might be a Microsoftism. >> >> Definitively. I just suspect it may have bled over into nominally >> Linux systems. >> >> All goes back to "raw" and "cooked" mode in DOS, which originated >> there, SFAIK. > > No, raw and cooked mode is a Unix thing and predates DOS by a long > time.On Unix, tty devices (like serial ports) can be in raw or > canonical (AKA "cooked") mode. Ah; so it's tty devices, not all files. Where in DOS*, I'm thinking it was extended to all files - fopen(...,"rb") being the override to be binary. *and by extension Windows... > When in cooked mode, you can enable > things like conversion of cr->lf or vice versa, mapping > lowercase->uppercase, handling various control characters, xon/xoff > flow control, and so on. > Right. stty ,termios.h ad nauseum. Kewl. Thanks, Grant. -- Les Cargill
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2014-04-15 15:15 +0000 |
| Message-ID | <lijie5$709$2@reader1.panix.com> |
| In reply to | #664 |
On 2014-04-15, Les Cargill <lcargill99@comcast.com> wrote:
>>> All goes back to "raw" and "cooked" mode in DOS, which originated
>>> there, SFAIK.
>>
>> No, raw and cooked mode is a Unix thing and predates DOS by a long
>> time.On Unix, tty devices (like serial ports) can be in raw or
>> canonical (AKA "cooked") mode.
>
> Ah; so it's tty devices, not all files.
Right. It's something you configure using termios.h and friends
after you've opened the file.
> Where in DOS*, I'm thinking it was extended to all files -
> fopen(...,"rb") being the override to be binary.
Yes, I think that was common practice for fopen() provided with many
DOS compilers. I don't remember if there was a corresponding option
to open() as you mentioned, but I wouldn't be surprised.
> *and by extension Windows...
>
>> When in cooked mode, you can enable things like conversion of cr->lf
>> or vice versa, mapping lowercase->uppercase, handling various control
>> characters, xon/xoff flow control, and so on.
>
> Right. stty ,termios.h ad nauseum. Kewl.
Yep, where Unix's "everything is just a stream of bytes" model starts
to unravel.
--
Grant Edwards grant.b.edwards Yow! NEWARK has been
at REZONED!! DES MOINES has
gmail.com been REZONED!!
[toc] | [prev] | [next] | [standalone]
| From | David <no@spam.please> |
|---|---|
| Date | 2014-02-14 13:13 +0000 |
| Message-ID | <ldl4q2$r2l$1@dont-email.me> |
| In reply to | #634 |
At Thu, 13 Feb 2014 18:39:23 -0600, Les Cargill rearranged some electrons to write: > I'm porting some code from one Linux to another. It uses serial ports. > > As opened, the serial port converts 0x0d characters to 0x0a characters. > > I have done some googling to find which *opts() functions control > setting the file referred to by the handle for the serial port to be a > pure, binary file. I see the one that turns off this conversion, but I > want all characters to be received completely untrammelled. > > I also need to use fopen()... fclose(), so ORed together last-argument > things in open() are out. > > What's a good website that shows *all* the serial port options for > Linux? Try: http://www.tldp.org/HOWTO/html_single/Serial-HOWTO/
[toc] | [prev] | [standalone]
Back to top | Article view | comp.os.linux.embedded
csiph-web