1

I'm trying to send a command to a device using windows terminal, so what I do is

[System.IO.Ports.SerialPort]::getportnames()

For getting the good port, then

$port= new-Object System.IO.Ports.SerialPort COM3,9600,None,8,one
$port.open()

for configure it and open it

After that I'm trying to send a command in this form :

<DLE> <command> <CR> 

But I clearly have no idea how to do it, I try with the command OFF (easiest because it power off my device) So I test with this code :

[Byte[]] $request = 0x10,79,70,70,0x0D
$port.Write($request)

Didn't work so I test this :

[Char[]] $request = 0x10,"O","F","F",0x0D
$port.Write($request)

Same didn't work,thing is I don't know how to writing it's absolutly not explain in the manual of my device they just give the command form I wrote above and the list of command type OFF / SET / CLR ...

If someone can help me with this thanks :)

valkyrion
  • 11
  • 2

1 Answers1

0

I just succeeded. The successful syntax of the command was:

[Byte[]] $request = 0x10,0x4F,0x46,0x46,0x0D 
$port.Write($request,0,$request.count)

I'm still a little surprised there is absolutely no explanation in the manual of my device. Maybe the command was obvious, but not for me. It was the first time I used PowerShell.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
valkyrion
  • 11
  • 2