Iot: Is any way to send command through UART port?

Created on 24 Dec 2019  路  3Comments  路  Source: dotnet/iot

I want to send my command through the UART port to a module with asp.net core application which is run in Raspbian OS on Raspberry Pi 3.

When I use System.IO.Ports.SerialPort to open the serial port, I got UnathorizedAccessException. Is any way exist for send and receive command with UART port?

question

Most helpful comment

Thank you @krwq for your suggestions, I can change the permission of the Raspberry Pi UART port with the following command :
sudo chmod 777 /dev/ttyS0

To check permission also can use this command :
ls -l /dev/ttyS0

After set permission on the UART port, my problem has been solved.
Thanks.

All 3 comments

  1. Make sure to enable UART in raspi-config
  2. change permissions of your serial port file so that you can run it as regular user (use udev to auto-change permissions) - as a quick test you can try running your app as sudo

@Parsakarami where you able to get it working after applying @krwq suggestions?

I'll go ahead and close this given this was a question and it was answered.

Thank you @krwq for your suggestions, I can change the permission of the Raspberry Pi UART port with the following command :
sudo chmod 777 /dev/ttyS0

To check permission also can use this command :
ls -l /dev/ttyS0

After set permission on the UART port, my problem has been solved.
Thanks.

Was this page helpful?
0 / 5 - 0 ratings