Quantcast

Serial Port for MODBUS/RS485

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Serial Port for MODBUS/RS485

Daniele Salvatore Albano
Hi,

for i project i'm working on, i decided to use an android tablet (with
mono for android) as central unit instead to build, from scratch,
everything i need (using an i.MX233 for example or a Mini2440).

But looking for Serial Port support i've seen that System.IO.Ports is
missing. While i understand that some (many) custom kernels doesn't
support serial ports (internal and usb ones), i really need it :)
The tablet i choose for the project is chinese and is rooted with
semi-vanilla ics distribution (well, all usbserial modules are there
and my adapters, ftdi<->rs485 and profilic for rs232, works out of the
box)

Can i do something to obtain support for Serial Ports on mono for
android? Can i grab System.IO.Ports from mono project (i think not,
i've seen that a native helper called MonoPosixHelper is used)

I imagine that i need to write a simple native library to handle this
situation, but i need to write it using JNI or i can write a native
android library and use it with pinvokes on mono for android? I've
wrote some stuff, some time ago, to handle serial ports and it works
fine so if i can use it without interfacing with JNI would be great!
:) Otherwise i'll write a JNI wrapper around my library and use it
with mono for android.

--
Daniele Salvatore Albano
---
IT Consultant
Website Design and Development
Software Engineer and Developer
Linux Servers SetUp And Administration
Embedded Network Solutions

http://www.daccii.it
http://www.itechcon.it
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Serial Port for MODBUS/RS485

Jonathan Pryor-2
On Nov 5, 2012, at 8:06 PM, Daniele Salvatore Albano <[hidden email]> wrote:
> While i understand that some (many) custom kernels doesn't support serial ports (internal and usb ones), i really need it :)

> Can i do something to obtain support for Serial Ports on mono for android? Can i grab System.IO.Ports from mono project (i think not, i've seen that a native helper called MonoPosixHelper is used).

You'd need to grab both: use the Android NDK to compile mono/support into MonoPosixHelper, and compile mcs/class/System/Sytem.IO.Ports into your application. In theory both should be do-able, but I haven't tried (and thus don't know what complications you may run into).

> I imagine that i need to write a simple native library to handle this situation,

That would be the NDK-built libMonoPosixHelper.so.

> or i can write a native android library and use it with pinvokes on mono for android?

P/Invoke is fully supported. You can certainly DllImport into an app-bundled MonoPosixHelper.

> I've wrote some stuff, some time ago, to handle serial ports and it works fine so if i can use it without interfacing with JNI would be great!

That works too.

 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Serial Port for MODBUS/RS485

Daniele Salvatore Albano
After few hours of happy hacking i successfully compiled
libMonoPosixHelper using ndk on windows and it works like a charm with
mono System.IO.Ports (i dropped some code) and NModbus (that uses
log4net and in which i removed a lot of unuseful and unsupported
code).

Just one thing: i discovered that android doesn't load native
libraries dependencies so i make a BIG library containing:
- libeglib, from mono-master
- libz, from mono-master (i just added stuff in support folder)
- some functions from libm (sqrt and all the necessary stuff) because
libeglib uses them for hashtables

Now it working fine and it's very very very nice, my basilar weather
station (just pressure and temperature) is happily attached to my
chinese android tablet with android 4.0.3 and seems to works fine
(twenty minutes without crash :))

Big question: i've seen that libz and libeglib uses mit/bsd style
license, what license is in use for libMonoPosixHelper?


Thank you!

2012/11/6 Jonathan Pryor <[hidden email]>:

> On Nov 5, 2012, at 8:06 PM, Daniele Salvatore Albano <[hidden email]> wrote:
>> While i understand that some (many) custom kernels doesn't support serial ports (internal and usb ones), i really need it :)
>
>> Can i do something to obtain support for Serial Ports on mono for android? Can i grab System.IO.Ports from mono project (i think not, i've seen that a native helper called MonoPosixHelper is used).
>
> You'd need to grab both: use the Android NDK to compile mono/support into MonoPosixHelper, and compile mcs/class/System/Sytem.IO.Ports into your application. In theory both should be do-able, but I haven't tried (and thus don't know what complications you may run into).
>
>> I imagine that i need to write a simple native library to handle this situation,
>
> That would be the NDK-built libMonoPosixHelper.so.
>
>> or i can write a native android library and use it with pinvokes on mono for android?
>
> P/Invoke is fully supported. You can certainly DllImport into an app-bundled MonoPosixHelper.
>
>> I've wrote some stuff, some time ago, to handle serial ports and it works fine so if i can use it without interfacing with JNI would be great!
>
> That works too.
>
>  - Jon
>
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid



--
Daniele Salvatore Albano
---
IT Consultant
Website Design and Development
Software Engineer and Developer
Linux Servers SetUp And Administration
Embedded Network Solutions

http://www.daccii.it
http://www.itechcon.it
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Serial Port for MODBUS/RS485

Miguel de Icaza-2

Big question: i've seen that libz and libeglib uses mit/bsd style
license, what license is in use for libMonoPosixHelper?

It contains LGPL and MIT X11 code.

But we consider that part of Mono, so if you are using it with Mono For Android, you have a commercial license to the dual-licensed LGPL components.

Miguel


Thank you!

2012/11/6 Jonathan Pryor <[hidden email]>:
> On Nov 5, 2012, at 8:06 PM, Daniele Salvatore Albano <[hidden email]> wrote:
>> While i understand that some (many) custom kernels doesn't support serial ports (internal and usb ones), i really need it :)
>
>> Can i do something to obtain support for Serial Ports on mono for android? Can i grab System.IO.Ports from mono project (i think not, i've seen that a native helper called MonoPosixHelper is used).
>
> You'd need to grab both: use the Android NDK to compile mono/support into MonoPosixHelper, and compile mcs/class/System/Sytem.IO.Ports into your application. In theory both should be do-able, but I haven't tried (and thus don't know what complications you may run into).
>
>> I imagine that i need to write a simple native library to handle this situation,
>
> That would be the NDK-built libMonoPosixHelper.so.
>
>> or i can write a native android library and use it with pinvokes on mono for android?
>
> P/Invoke is fully supported. You can certainly DllImport into an app-bundled MonoPosixHelper.
>
>> I've wrote some stuff, some time ago, to handle serial ports and it works fine so if i can use it without interfacing with JNI would be great!
>
> That works too.
>
>  - Jon
>
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid



--
Daniele Salvatore Albano
---
IT Consultant
Website Design and Development
Software Engineer and Developer
Linux Servers SetUp And Administration
Embedded Network Solutions

http://www.daccii.it
http://www.itechcon.it
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Serial Port for MODBUS/RS485

poorsam
Hi
colud you please explain how did you compiled MonoPosixHelper support in windows?
Thanks alot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Serial Port for MODBUS/RS485

Daniele Salvatore Albano
In reply to this post by Miguel de Icaza-2
Thank you!

By the way, is it a problem if i put the compiled library, for people
that doesn't want to setup up the ndk and all necessary stuff, along
with sources and compile instructions, on my website?

I think that libMonoPosixHelper may be really useful and it would let
people to reuse unported parts of mono on Mono for Android.

2012/11/13 Miguel de Icaza <[hidden email]>:

>
>> Big question: i've seen that libz and libeglib uses mit/bsd style
>> license, what license is in use for libMonoPosixHelper?
>
>
> It contains LGPL and MIT X11 code.
>
> But we consider that part of Mono, so if you are using it with Mono For
> Android, you have a commercial license to the dual-licensed LGPL components.
>
> Miguel
>>
>>
>>
>> Thank you!
>>
>> 2012/11/6 Jonathan Pryor <[hidden email]>:
>> > On Nov 5, 2012, at 8:06 PM, Daniele Salvatore Albano
>> > <[hidden email]> wrote:
>> >> While i understand that some (many) custom kernels doesn't support
>> >> serial ports (internal and usb ones), i really need it :)
>> >
>> >> Can i do something to obtain support for Serial Ports on mono for
>> >> android? Can i grab System.IO.Ports from mono project (i think not, i've
>> >> seen that a native helper called MonoPosixHelper is used).
>> >
>> > You'd need to grab both: use the Android NDK to compile mono/support
>> > into MonoPosixHelper, and compile mcs/class/System/Sytem.IO.Ports into your
>> > application. In theory both should be do-able, but I haven't tried (and thus
>> > don't know what complications you may run into).
>> >
>> >> I imagine that i need to write a simple native library to handle this
>> >> situation,
>> >
>> > That would be the NDK-built libMonoPosixHelper.so.
>> >
>> >> or i can write a native android library and use it with pinvokes on
>> >> mono for android?
>> >
>> > P/Invoke is fully supported. You can certainly DllImport into an
>> > app-bundled MonoPosixHelper.
>> >
>> >> I've wrote some stuff, some time ago, to handle serial ports and it
>> >> works fine so if i can use it without interfacing with JNI would be great!
>> >
>> > That works too.
>> >
>> >  - Jon
>> >
>> > _______________________________________________
>> > Monodroid mailing list
>> > [hidden email]
>> >
>> > UNSUBSCRIBE INFORMATION:
>> > http://lists.ximian.com/mailman/listinfo/monodroid
>>
>>
>>
>> --
>> Daniele Salvatore Albano
>> ---
>> IT Consultant
>> Website Design and Development
>> Software Engineer and Developer
>> Linux Servers SetUp And Administration
>> Embedded Network Solutions
>>
>> http://www.daccii.it
>> http://www.itechcon.it
>> _______________________________________________
>> Monodroid mailing list
>> [hidden email]
>>
>> UNSUBSCRIBE INFORMATION:
>> http://lists.ximian.com/mailman/listinfo/monodroid
>
>
>
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>



--
Daniele Salvatore Albano
---
IT Consultant
Website Design and Development
Software Engineer and Developer
Linux Servers SetUp And Administration
Embedded Network Solutions

http://www.daccii.it
http://www.itechcon.it
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Serial Port for MODBUS/RS485

Igor
In reply to this post by poorsam
Daniele, It would be great if you could share the compiled binaries, otherwise it seems I'll do this again by myself )

BTW, does SerialPort.GetPortNames returns something meaningful on your devices?

  Igor


On Wed, Nov 14, 2012 at 9:14 PM, poorsam <[hidden email]> wrote:
Hi
colud you please explain how did you compiled MonoPosixHelper support in
windows?
Thanks alot



--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Serial-Port-for-MODBUS-RS485-tp5712317p5712374.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Serial Port for MODBUS/RS485

Daniele Salvatore Albano
@poorsam

i used android ndk and a couple of batch that set some env variables
and "simulate" a make-like system (really really really semplified)


@Igor Russkih

Sure! I'm out for work, here i've only binaries and not modified
source so i can upload only the binary file right now, the next week
i'll upload sources too.

SerialPort.GetPortNames returns some stuff partially right, but
partially because on it tries to list only ttyS and ttyUSB devices.
I fixed this (but it works only on linux based systems) changing the
part that read from /dev to read from /sys/bus/tty (i check if inside
folders there is a device symlink to ensure that it's a real device)

It's works fine.

I've made a quite simple and stupid library to read device infos from
/sys using an extension method (i need this because on my tablet i
need to connect more than one usb<->ttl converter, an usb <-> rs485
and an usb <-> ttl)

2012/11/19 Igor Russkih <[hidden email]>:

> Daniele, It would be great if you could share the compiled binaries,
> otherwise it seems I'll do this again by myself )
>
> BTW, does SerialPort.GetPortNames returns something meaningful on your
> devices?
>
>   Igor
>
>
>
> On Wed, Nov 14, 2012 at 9:14 PM, poorsam <[hidden email]> wrote:
>>
>> Hi
>> colud you please explain how did you compiled MonoPosixHelper support in
>> windows?
>> Thanks alot
>>
>>
>>
>> --
>> View this message in context:
>> http://mono-for-android.1047100.n5.nabble.com/Serial-Port-for-MODBUS-RS485-tp5712317p5712374.html
>> Sent from the Mono for Android mailing list archive at Nabble.com.
>> _______________________________________________
>> Monodroid mailing list
>> [hidden email]
>>
>> UNSUBSCRIBE INFORMATION:
>> http://lists.ximian.com/mailman/listinfo/monodroid
>
>
>
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>



--
Daniele Salvatore Albano
---
IT Consultant
Website Design and Development
Software Engineer and Developer
Linux Servers SetUp And Administration
Embedded Network Solutions

http://www.daccii.it
http://www.itechcon.it
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Serial Port for MODBUS/RS485

poorsam
This post has NOT been accepted by the mailing list yet.
Hello Daniele
Thanks for your replay
as im had never linux experience or ndk too and i have just C# experience
i wonder if you could share the patched library or explain in detail how to do this by myself.
Thanks again
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Serial Port for MODBUS/RS485

Igor
In reply to this post by Daniele Salvatore Albano
Daniel, have you had a chance to look into sharing this?

  Igor


On Mon, Nov 19, 2012 at 5:45 PM, Daniele Salvatore Albano <[hidden email]> wrote:
@poorsam

i used android ndk and a couple of batch that set some env variables
and "simulate" a make-like system (really really really semplified)


@Igor Russkih

Sure! I'm out for work, here i've only binaries and not modified
source so i can upload only the binary file right now, the next week
i'll upload sources too.

SerialPort.GetPortNames returns some stuff partially right, but
partially because on it tries to list only ttyS and ttyUSB devices.
I fixed this (but it works only on linux based systems) changing the
part that read from /dev to read from /sys/bus/tty (i check if inside
folders there is a device symlink to ensure that it's a real device)

It's works fine.

I've made a quite simple and stupid library to read device infos from
/sys using an extension method (i need this because on my tablet i
need to connect more than one usb<->ttl converter, an usb <-> rs485
and an usb <-> ttl)

2012/11/19 Igor Russkih <[hidden email]>:
> Daniele, It would be great if you could share the compiled binaries,
> otherwise it seems I'll do this again by myself )
>
> BTW, does SerialPort.GetPortNames returns something meaningful on your
> devices?
>
>   Igor
>
>
>
> On Wed, Nov 14, 2012 at 9:14 PM, poorsam <[hidden email]> wrote:
>>
>> Hi
>> colud you please explain how did you compiled MonoPosixHelper support in
>> windows?
>> Thanks alot
>>
>>
>>
>> --
>> View this message in context:
>> http://mono-for-android.1047100.n5.nabble.com/Serial-Port-for-MODBUS-RS485-tp5712317p5712374.html
>> Sent from the Mono for Android mailing list archive at Nabble.com.
>> _______________________________________________
>> Monodroid mailing list
>> [hidden email]
>>
>> UNSUBSCRIBE INFORMATION:
>> http://lists.ximian.com/mailman/listinfo/monodroid
>
>
>
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>



--
Daniele Salvatore Albano
---
IT Consultant
Website Design and Development
Software Engineer and Developer
Linux Servers SetUp And Administration
Embedded Network Solutions

http://www.daccii.it
http://www.itechcon.it
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Loading...