Hi,

There's some support for unix serial devices.  You can look at the
example in extra/io/serial/
unix/unix-tests.factor.

Basically you make a serial object, set the path to the device,
something like "/dev/ttyS0" (you will need permissions, chmod
/det/ttyS0 ...), set the baud rate, flags, etc.  Once you create your
serial object, you can call open-serial on it, and it should return a
duplex stream which you can read and write like regular streams.  You
might need to call some of the unix libc apis for serial ports; again,
look in the unix-tests file.

Once you have your duplex-stream serial object, you can write to it:
"abc\n" over stream-write dup stream-flush

Or read from it:
10 over stream-read

Let me know if you have any problems.

Doug





On Wed, Jun 8, 2011 at 5:02 PM, John Porubek <[email protected]> wrote:
> Hello,
>
> I'm a long time devotee of Forth. I recently stumbled upon Factor and
> what I've seen and read is very interesting and quite exciting. I'm
> even beginning to better understand some terms and concepts I've seen
> bandied around with other modern languages now that I can see them in
> a more Forth-like context.
>
> When learning a new programming language, I find it helps a great deal
> to try coding some simple projects in that language. I'm currently
> trying to communicate with a development board using a serial port
> (actually serial over USB). I've been successful using Forth to do
> this in both Linux and Windows, but I'm a little at a loss to know how
> to do it using Factor. Can someone explain how to open a serial port
> in Factor and read and write a character? (The equivalent of "key" and
> "emit" in Forth. Extra points for "key?".) Use any port, any baud
> rate, etc. I can adapt an example to my particulars.
>
> I have a strong feeling that "unix-tests.factor" in
> "./extra/io/serial/unix" contains some strong clues, but the lightbulb
> over my head still isn't quite turning on. Any help I can get will be
> appreciated. If not, I'll keep on plugging away and get there
> eventually (I'm nothing if not tenacious!). Then maybe I'll be able to
> help someone else.
>
> Thanks,
>
> --John
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to