Powershell serial communication with Arduino
i pulling hair out trying figure out why can't communicate arduino through windows powershell (which relies on .net components). hopefully others. the final code is:
the line made difference this:
$port.dtrenable = "true"
also, have arduino write response after executes every command, hence read afterwards.
hope helps someone.
code: [select]
$port = new-object system.io.ports.serialport
$port.portname = "com6"
$port.baudrate = "9600"
$port.parity = "none"
$port.databits = 8
$port.stopbits = 1
$port.readtimeout = 9000 # 9 seconds
$port.dtrenable = "true"
$port.open() #opens serial connection
start-sleep 2 # wait 2 seconds until arduino ready
$port.write("93c") #writes content serial connection
try
{
while($myinput = $port.readline())
{
$myinput
}
}
catch [timeoutexception]
{
# error handling code here
}
finally
{
# cleanup code goes here
}
$port.close() #closes serial connection
the line made difference this:
$port.dtrenable = "true"
also, have arduino write response after executes every command, hence read afterwards.
hope helps someone.
most interesting. how input pc serial port arduino displayed powershell? use batch files send strings com port, cmd.exe doesn't have capability read serial port input buffer.
Arduino Forum > Forum 2005-2010 (read only) > Software > Interfacing > Powershell serial communication with Arduino
arduino
Comments
Post a Comment