27 lines
916 B
PowerShell
27 lines
916 B
PowerShell
# Hand-poll the RIO board over COM1 -- no game involved. Wire format per
|
|
# PCSerialPacket::SendPacket: [cmd][checksum = sum & 0x7F].
|
|
$p = New-Object System.IO.Ports.SerialPort COM1,9600,None,8,One
|
|
$p.DtrEnable = $true
|
|
$p.RtsEnable = $true
|
|
$p.ReadTimeout = 200
|
|
$p.Open()
|
|
'PORT OPEN CTS=' + $p.CtsHolding + ' DSR=' + $p.DsrHolding
|
|
|
|
function Send-Cmd([byte[]]$bytes, [string]$name) {
|
|
$p.DiscardInBuffer()
|
|
$p.Write($bytes, 0, $bytes.Length)
|
|
Start-Sleep -Milliseconds 700
|
|
$got = @()
|
|
while ($p.BytesToRead -gt 0) { $got += [byte]$p.ReadByte() }
|
|
$hex = ($got | ForEach-Object { $_.ToString('X2') }) -join ' '
|
|
"$name -> $($got.Count) byte(s): $hex"
|
|
}
|
|
|
|
Send-Cmd @([byte]0x80, [byte]0x00) 'CHECK 0x80'
|
|
Send-Cmd @([byte]0x81, [byte]0x01) 'VERSION 0x81'
|
|
Send-Cmd @([byte]0x82, [byte]0x02) 'ANALOG 0x82'
|
|
Start-Sleep -Seconds 2
|
|
Send-Cmd @([byte]0x82, [byte]0x02) 'ANALOG again'
|
|
$p.Close()
|
|
'DONE'
|