This is the current definition of <serial-stream>:

    : <serial-stream> ( path encoding -- duplex )
        [ open-r/w dup ] dip <encoder-duplex> ;

But ``open-r/w`` returns a win32-file, not an input-stream or output-stream.

Perhaps this would work:

    : <serial-stream> ( path encoding -- duplex )
        [ open-r/w [ <input-port> ] [ output-port> ] bi ] dip
<encoder-duplex> ;

It makes sure to turn the win32-file handle into input and output streams
first.

If you get it working, I'd love a pull request with fixes, any
documentation you cared to write, and any tests that could run on a default
windows VM.  :-)

Best,
John.


On Sun, Mar 5, 2017 at 11:42 AM, Alexander Ilin <ajs...@yandex.ru> wrote:

> Hello!
>
>   I have tried using io.serial in Windows today. Normally, serial IO is
> pretty straightforward in Windows: you open a file named "COM1", possibly
> set the baud rate, and off you go reading and writing.
>
>   Not so much in Factor.
>
>   I have imported the io.serial vocab and perused its empty documentation.
> Well, do I really need any documentation, I thought to myself. How hard can
> it be, really?
>
>   So I did the first thing that came to mind:
>
> 9600 "COM3" <serial-port>
>
>   The error was:
> Generic word default-serial-flags does not define a method for the word
> class.
> Dispatching on object: windows
>
>   Well, o-kay... What does it do on other platforms, then?
>
> M: unix default-serial-flags
>     flags{ IGNPAR ICRNL } >>iflag
>     flags{ } >>oflag
>     flags{ CS8 CLOCAL CREAD } >>cflag
>     flags{ ICANON } >>lflag ;
>
>   Those flag names could not be more unhelpful if they tried. That's dead
> end number one.
>
>   But wait, maybe there's something useful in io.serial.windows? A-ha!
> <serial-stream>! Let's check it out:
>
> "COM3" ascii <serial-stream>
>
>   It worked! I have an object that seems to be a stream of some sort.
> Let's try reading from it:
>
> 5 over stream-read
>
> Generic word stream-read1 does not define a method for the win32-file
> class.
> Dispatching on object: T{ win32-file f f f ALIEN: 134 f }
>
>   That's dead end number two.
>
>   Does anyone know how to get past either of these?
>
> ---=====---
>  Александр
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to