OpenLogics / MewtocolNet

⭐ A Mewtocol protocol library to interface with Panasonic PLCs over TCP/Serial written in C#
https://na.industrial.panasonic.com/
GNU General Public License v3.0
26 stars 7 forks source link

Serial Port on MAUI(Android) #10

Open rivenww opened 1 year ago

rivenww commented 1 year ago

Well, I am interested in this repo and I found this repo because I'm investigating a way to communicate with a PLC on android device.

Actually, it might work well on MAUI for Android as I made a demo to do some simple operations.

Now I am learning how to implement a serial version for this repo, but for Android it usually use Android USB Host Mode (OTG) to communicate with a device via Serial port.

So my question is, is it possible to implement it with a cross platform way? Cuz for IOS or some other CLR there may be no same API as on Windows or Android.

rivenww commented 1 year ago

I roughly read the code of this project, and I think I can implement a serial communication class for Android devices based on the MewtocolInterface class.

This class will not use the System.IO.Ports namespace in order to allow it to run on Android devices.

This repo is quite wonderful😊

Sandoun commented 1 year ago

Hi @rivenww,

sorry for my late response. I have reworked the whole repository from the ground up this also includes an implementation of System.IO.Ports. Still have to do some householding and cleanup but i have tested the serial feature with some PLCs.

The builder pattern for PLC interfaces has changed quite a lot, this is an example for a connection to COM4 with 19200 baud rate:

using(IPlc plc = Mewtocol.Serial("COM4", BaudRate._19200).Build()) {
await plc.ConnectAsync();
}

There are now also interfaces for IPlc, IPlcEthernet, and IPlcSerial.

Feel free to take a look at my latest commits, the changes were made for future additions like this one in mind!

I don't know if System.IO.Ports will work with android, but yeah if not feel free to make another interface for MAUI based on the IPlc interface!

My only concern is that if you need an additional library for the android serial interface it might be wiser to separate the feature into an other package and namespace like: MewtocolNet.MAUI to prevent bloating of the core

Edit:

I made some new subprojects during the rewrite for example the WPF Example. The wiki and readme are unfortunately not up to date...