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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.157.35 with SMTP id wj3mr8688801pab.11.1391979629326; Sun, 09 Feb 2014 13:00:29 -0800 (PST) X-Received: by 10.140.34.56 with SMTP id k53mr12324qgk.9.1391979629274; Sun, 09 Feb 2014 13:00:29 -0800 (PST) Path: border2.nntp.dca.giganews.com!nntp.giganews.com!news.glorb.com!c10no12928430igq.0!news-out.google.com!y18ni5935qap.1!nntp.google.com!k15no14123336qaq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 9 Feb 2014 13:00:29 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=46.195.38.57; posting-account=3_reEwoAAAC163IAIrx427KYmwahFuh9 NNTP-Posting-Host: 46.195.38.57 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6d8fc500-b333-42d6-a7bc-e95df93df28c@googlegroups.com> Subject: Re: Hello, and help with GNAT and Windows USB programming From: =?ISO-8859-1?Q?bj=F6rn_lundin?= Injection-Date: Sun, 09 Feb 2014 21:00:29 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.dca.giganews.com comp.lang.ada:184739 Date: 2014-02-09T13:00:29-08:00 List-Id: Den s=F6ndagen den 9:e februari 2014 kl. 20:59:41 UTC+1 skrev Gumpy: > 2. Using GNAT, and potentially GNAT.Serial_Communications, how does one o= pen >a USB port and read and write character strings to it (the thermocoupl= e >interface has a simple character based command language for setup and ta= king >temperature readings).=20 if the card is using serial comm, then you want to by a usb-to-serial conve= rter. It will act like a virtual com-port then Use it like this (the code spoke with an Arduaino)=20 with GNAT.Serial_Communications; with Ada.Streams; procedure Serial_Talker is TTY : GNAT.Serial_Communications.Serial_Port; ------------------------ function String_To_Stream ( The_String : in String) return Ada.Streams.St= ream_Element_Array is Return_Value : Ada.Streams.Stream_Element_Array(1..The_String'length); begin for Count in 1..Ada.Streams.Stream_Element_Offset(The_String'Length) lo= op Return_Value(Count) :=3D Character'pos(The_String(Integer(Count))); end loop; return Return_Value(1..The_String'Length); end String_To_Stream; ------------------------ begin TTY.Open(Name =3D> "/dev/ttyUSB0"); TTY.Set (Rate =3D> GNAT.Serial_Communications.B9600, Bits =3D> GNAT.Serial_Communications.CS8, Stop_Bits =3D> GNAT.Serial_Communications.One, Parity =3D> GNAT.Serial_Communications.None, Block =3D> True); TTY.Write(Buffer =3D> (String_To_Stream("1"))); -- whatever you'd like TTY.Close; end Serial_Talker; need -gnat05 to compile it was on Linux, and on Win TTY.Open(Name =3D> "/dev/ttyUSB0"); would be like TTY.Open(Name =3D> "COM4"); or perhaps=20 TTY.Open(Name =3D> "COM4:"); or=20 TTY.Open(Name =3D> "\\.\COM4"); or=20 TTY.Open(Name =3D> "\\\\.\\COM4"); But i'm not sure you'd use serial comm though. I have a velleman k8055 which I interfaced with bundled dlls. No serial comm at all. It involved looping around the usb devices and finding the card, with id of manufacturer etc. I have it on a broken machine, but I might be able to dig it up tomorrow, if you think it will help >=20 > 3. Does anyone have any specific code examples for communicating on a USB= >port that they would like to share, or a link to some example(s) online >= somewhere?=20 =20 yes, as above /Bj=F6rn