Powershell and the Sentry Hardware – how to interface.
Serial port access using Powershell – as covered in the article entitled Powershell and serial ports for the Sentry Project does not cover that actual syntax of the commands required to send instruction to the Sentry project hardware only the basic serial IO commands available.
So digging deeper to look at the command outputs formats for the Sentry device and the powershell commands to issue them gives the following simple script to open the port issue some commands for output and close the port:
# clear the power shell output pane
cls
# setup the serial port
$port = new-Object System.IO.Ports.SerialPort COM1,9600,None,8,two
# ensure closed from any previous debugging
$port.close()
# output status message to the powershell pane
write “Starting”
# open the serial port
$port.open()
# clear all displays
# note the `r inside the quotes which escapes the special character for carriage return
# first clear the LCD screen
$port.write(“:D3DH`r”)
# then clear the two matrices
$port.write(“:D1KW`r”)
$port.write(“:D2KW`r”)
# sleep for a few seconds
start-sleep -s 3
# write the @ symbol to both matrices
$port.write(“:D1CB64`r”)
$port.write(“:D2CB64`r”)
# clear the lcd panel
$port.write(“:D3DH`r”)
start-sleep -s 3
#write B to first matrix and A to second
$port.write(“:D1CR66`r”)
$port.write(“:D2CR65`r”)
#put the current time in String variable
[STRING]$tnow = get-date -displayhint time
# write “showtime” to first line of LCD
$port.write(“:D3BT`”Showtime`”`r”)
# important to pause and let panel catch up before this next command
start-sleep -s 3
# move cursor to first postion on second line of LCD panel
$port.write(“:D3BP40`r”)
start-sleep -s 3
# write “showtime2” to second line
$port.write(“:D3BT`”Showtime2`”`r”)
start-sleep -s 3
# clear displays and close port
$port.write(“:D3DH`r”)
$port.write(“:D1KW`r”)
$port.write(“:D2KW`r”)
$port.close()
-
Summary
So this code shows the means of interfacing between Powershell and the Sentry Hardware to display output. The next article in the series will show the interaction between Powershell – Intellipool Network Monitor (INM) and the Sentry Hardware.