From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,cc65ab136f46904d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: GNAT.Serial_Communications Date: Wed, 20 Apr 2011 20:46:37 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <9af0087d-9637-40d9-8c30-2e06c2d1e4f4@o26g2000vby.googlegroups.com> <31dd80b2-3fd3-4078-8774-c396a52c94a0@r6g2000vbz.googlegroups.com> <0d509f1c-4ca7-4595-a026-65c108558d76@bl1g2000vbb.googlegroups.com> <35515c03-f565-4fc4-ac1c-e9b7268123b3@dn9g2000vbb.googlegroups.com> <1144e8e4-4193-4ffd-a8d2-145c38993eb2@p16g2000vbi.googlegroups.com> <6301289c-f450-4d7f-8391-01e17d2555b9@z27g2000prz.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 20 Apr 2011 20:46:37 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="mlmG41Hk0NvblPCVoy/sxg"; logging-data="16170"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+iwBNLbSBmjwwh3K0g5o3WDFOsvIVJsWM=" User-Agent: Pan/0.133 (House of Butterflies) Cancel-Lock: sha1:n8w594S/jyMZlbLoqjrVkqjK9zQ= Xref: g2news1.google.com comp.lang.ada:18930 Date: 2011-04-20T20:46:37+00:00 List-Id: On Tue, 19 Apr 2011 13:32:34 +0000, Simon Clubley wrote: > On 2011-04-19, tonyg wrote: >> >> Just to let you all know ( I'm sure the world was waiting with baited >> breath!) that thanks to the help received, its now all working. I'll >> document what the problem was ... >> stty --file=/dev/ttyUSB0 -crtscts >> >> However - any ada program compiled with the gnat serial communications >> package if run again will reset the port to add flow control so this >> needs it will need to be done again. Which is unfortunate for me and > > Interesting. I would not expect that; Having just read g-sercom-linux.adb, this is now exactly what I would expect. The "Set" procedure in Gnat.Serial_Communications uses "tcsetattr" and "tcgetattr" C syscalls to do the job of setting baud rate ... "man tcsetattr" should give you the relevant information. Unfortunately it uses the pseudo-code tcgetattr(current settings); overwrite baud rate and other things you want to set; overwrite control settings inc. ctsrts for good measure tcsetattr(current settings); to do the job. See g-sercom-linux.adb for more details. It's very easy to understand what it's doing. Forget my earlier remarks about sysfs etc (maybe someday, it's clearly the intent to allow control that way, but for an "obsolete" interface it's not going to get much priority). Also forget using ioctl calls; tc[g|s]etattr are a good wrapper over ioctl without the variadic problems. So you are left with two options: (1) modify g-sercom-linux.adb to do the job, or at least, what it's supposed to (not corrupt settings unnecessarily). Then ... what has to happen to regenerate the GNAT.Serial_Communications package? Rebuild libada, or does the change happen next time you build your app? I am showing my ignorance of Gnat here... Then perhaps, submit patches upstream? (2) Copy the basic approach from procedure Set. Namely, after opening the port, import and use tcgetattr, tcsetattr in your own code. - Brian