[Mono-list] serial port with mono on freebsd
Carlos Solorzano
carlos at applianz.com
Thu May 11 13:01:51 EDT 2006
Tom Opgenorth wrote:
> On 5/11/06, Carlos Solorzano <carlos at applianz.com> wrote:
>> Usually I just read bytes, each device may send the bytes based on
>> some protocol they have,
> Thanks. So is it just as simple as opening a Stream of some sort and
> capturing the bytes? Would you know of any code samples for reading
> from a serial port in Windows?
>
> (P.S. sorry for the hijack)
>
I think it depends on whether you are using .net 2.0 or not. I think on
.net 2.0 the SerialPort classes are included on the microsoft framework
(someone correct me if I am wrong). I have a package I got from
somewhere long time ago (made by MS) that implemented System.IO.Ports
for .net 1.0/1.1, that library had almost the same API as .net 2.0 and
mono, so I made a few modification to it so it would work on both Linux
and Windows without the need of a recompile. The only problem was that
on mono it seemed like the System.IO.Ports namespace is in System.dll
and on windows for me it was on SerialPort.dll so on Linux I do
something crazy which people are gonna laugh at, I make a symbolic link
of SerialPort.dll to System.dll and it works fine. If mono did some more
serious assembly checks it wouldn't work, specially since all my
assemblies are signed!
On both reading and writing from the serial port is really easy, I use
pretty much the same code. Mono hasn't implemented everything yet, like
you can't receive SerialPort events yet like you can on windows, a lot
of the Write methods were missing but enough functionality is there to
make it usable. I have not looked at the Mono serial ports classes in
several months so this may have changed a lot.
Hope that helped.
--Carlos
More information about the Mono-list
mailing list