1

I'm using IoT-Edge on my Raspberry Pi 3. Since IoT-edge isn't compatible with Windows 10 IoT Core on Raspberry Pi 3, my Raspberry is on Raspbian.

I'm trying to read my UART ports to read XBee sensor data.

My edge's modules are written in C# thus far.

I'm using Raspbian so I can't use the class System.IO.Ports.SerialPort since System.IO.Ports is only compatible on Windows system. Is there another way to read my UART ports inside my module? (I'm ready to write a module in something other than C# if I can deploy it the same way.)

If not, is there at least a way to read/write data from a shared file between containers/raspberry without manually changing docker container file binding mode each time we deploy a module version (since the default binding mode for docker container is read-only, but my Raspberry will have to send data to sensor too)?

tomlogic
  • 11,489
  • 3
  • 33
  • 59
Magnas
  • 869
  • 1
  • 5
  • 18

2 Answers2

2

You are right about .NET Core not supporting serial on Linux. The latest version of the Python SDK is ready to write Edge modules. We are working on a sample and development guidance on using it, but that's not out yet. Once we have the sample/guidance out (hopefully soon), you should be able to write your module in python and read/write from the serial port. I've confirmed that it works in an Edge container.

0

You can use .Net Core to read UART ports. .NET Core is a cross-platform, it supports Raspbian,and applications can be written in C#.You can refer to this topic about how to use System.IO.Ports.SerialPort in .Net Core.

Michael Xu
  • 4,382
  • 1
  • 8
  • 16
  • Unfortunately, when I deploy my module on my raspberry pi3 and looking logs, I get the error "this class is only available on Windows operating system" – Magnas Mar 14 '18 at 12:40
  • You can use SerialPortStream library, it can work on .net core. – Michael Xu Mar 15 '18 at 08:58
  • I don't know how to add libnserial.so.1 to my module's container. I tried to add the so file inside my project but still getting an error – Magnas Mar 16 '18 at 15:51
  • Yes, but docker containers don't seem to share LD_LIBRARY_PATH with their host – Magnas Mar 19 '18 at 09:59
  • @Magnas, you can refer to this [topic](https://stackoverflow.com/questions/27093612/in-a-dockerfile-how-to-update-path-environment-variable).Please try to declare LD_LIBRARY_PATH via ENV in your Dockerfile. – Michael Xu Mar 20 '18 at 08:14
  • Yes i forgot to update my comment but i succeed to do that! Thanks for the link, it's still interesting ! My problem now is that i can't access /dev/ttyS0 since iotedgectl doesn't not seems to launch container with privileged mode nor --device option. Is there a way to change that ? Should I instead launch iotedgectl in root ? – Magnas Mar 20 '18 at 09:40
  • Yes, I think you have to launch iotedgecrl in root. You can use this command ***`ls -l /dev/ttyS0`*** to check the owner of the device. – Michael Xu Mar 20 '18 at 09:57
  • I used `iotedgectl restart` on root, deployed my container with iot hub and nothing changed. I ran `exec ls /dev/` on my container an "ttyS0" doesn't appear on the list, only "tty". In my host machine (rpi3), ttyS0 has root as owner and dialout as group. – Magnas Mar 20 '18 at 10:07