[Mono-list] Mono, Foxboard G20, /dev/ttys2 no receive ?

Robert Jordan robertj at gmx.net
Wed Feb 22 14:43:14 UTC 2012

On 22.02.2012 14:59, salorob wrote:
> Hi Robert,
> Thankyou for your reply.
> The code that i simulate in Mono is this one. Simple Send And Receive:


		#define TIOCSRS485 0x542F
		// Set RS485 mode:
		rs485conf.flags |= SER_RS485_ENABLED;
		if (ioctl (fd, TIOCSRS485, &rs485conf) < 0) {
			printf("ioctl error\n");

You need to p/invoke ioctl from libc[1] and create a p/invoke
declaration for "struct serial_rs485"[1].

To be able to use ioctl, you must get the file handle of the
serial port. Unfortunately, the SerialPort[3] class does not
expose it, so you'd have to do it via reflection[2].
You must get the value of the field "fd"[4] from the
field "stream"[3] of the class SerialPort[3].


[1] http://www.mono-project.com/Interop_with_Native_Libraries
[2] http://msdn.microsoft.com/en-us/library/f7ykdhsy%28v=vs.71%29.aspx

More information about the Mono-list mailing list