Is it possible to access the built-in serial and the gpio ports via powershell on Windows Iot?
1 Answer
Did you try:
[System.IO.Ports.SerialPort]::getportnames()
COM1
$port= new-Object System.IO.Ports.SerialPort COM1,9600,None,8,one
$port.open()
$port.WriteLine("Hello world")
$port.Close()
And reading from a Serial Port
$port= new-Object System.IO.Ports.SerialPort COM1,9600,None,8,one
$port.Open()
$port.ReadLine()
Edit:
I found out on this site: https://social.msdn.microsoft.com/Forums/en-US/b9633593-377e-4d6f-b3a9-838de0555371/serialdevicefromidasync-always-returns-null-unless-the-serial-adapter-is-plugged-in-after-boot
Serial port is used by debugger for kernel and is not available to use by other devices. There is a solution described there, but I cant confirm if it is working as I don't have Windows on my PI2, it's just simply too much overhead with that.
-
This works fine on my PC, but not with the PI.
Unable to find type [System.IO.Ports.SerialPort]. At line:1 char:1 + [System.IO.Ports.SerialPort]::getportnames() + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.IO.Ports.SerialPort:TypeName) [], RuntimeException + FullyQualifiedErrorId : TypeNotFound
– magriiiCommented Dec 14, 2015 at 6:25