Powershell to get version number from Ness D16

Greetings,

First time poster here and newbie with regards to talking to my Ness D16 via the Ness Serial to IP adapter. I can confirm my adapter works as I see a data stream from the Alarm when connecting via Putty.

I am working on using powershell to send email alerts from the alarm when they occur. My panel is v7.8 which does not support the ‘heartbeat’ feature so I am trying to write my own in powershell that will run as a scheduled task. I want to send a status request to the alarm so that it outputs its version and use it as a heartbeat. This way I know my powershell ‘listener’ script is running when no alarm activity occurs over long periods of time.

I am having trouble sending the status update request to the alarm via powershell. I am also having trouble generating the correct string to request the version from the alarm so I am using the unsealed zone status request from the Ness_D8-D16_ASCII_protocol_rev13.pdf document (which is not easy to read).

So far I have this:

# 83000360S00E9 = unsealed zones status request

# Define the IP address and port of the remote device
$ipAddress = "192.168.0.5"  # Replace with the actual IP address
$port = 2401  # Replace with the actual port number

# Define the code to send as a text string
$codeToSend = "83000360S00E9"  # Replace with your code as a text string

try {
    # Create a TCP client and connect to the remote device
    $tcpClient = New-Object System.Net.Sockets.TcpClient
    $tcpClient.Connect($ipAddress, $port)

    # Convert the code to bytes
    $codeBytes = [System.Text.Encoding]::UTF8.GetBytes($codeToSend)
    write-host $codeBytes

    # Get the network stream for sending data
    $stream = $tcpClient.GetStream()

    # Send the code
    $stream.Write($codeBytes, 0, $codeBytes.Length)
    
    # Close the connection
    $tcpClient.Close()
    Write-Host "Code sent successfully."
} catch {Write-Host "An error occurred: $_"}

When trying the above, the alarm does not return any output.

Any Assistance would be greatly appreciated.

P.S. Apologies if this is not posted where it should be (just joined the community :slight_smile: )

I just found that I was calculating the checksum incorrectly. I found a good explanation on AusTech Forums which helped me. Hope it helps someone else:

As an example, if the message is a request for arming status: "8300360S14" - to get the checksum, we sum the message characters as ascii:
56 (8) + 51(3) + 48 (0) + 48(0) + 51(3) + 54(6) + 48(0) + 83(S) + 49(1) + 52(4) = 540 (or 0x21C).

So the next multiple of 0x100 after 0x21C is 0x300. 0x300 - 0x21C is 0xE4.
Or to use the equation above - Chk = 0x100 - (0x21C MOD 0x100) = 0x100 - 0x1C = 0xE4.

Thus we transmit “8300360S14E4”.

Also, I found this to send characters to a serial port:

Sometimes the obvious solutions are the simplest :slight_smile: