Here is a strange one. It’s been driving me nuts for a day or so. I’m trying to write an interface for a paging terminal that accepts message in TAP format. Part of the message string includes a 7 bit checksum. A nice explenation is located here: https://everything2.com/title/Telocator+Alphanumeric+Protocol
The only part giving me grief is the checksum. I’ve duplicated their example and the result is never correct. I’m probably missing something stupid. I’ve search all over and so far no one seems to have done this in PowerShell.
The process is pretty simple, take a line of text, do a 7 bit binary conversion, convert that to a decimal value, add it together and get a sum. Take that sum and convert it into a 3 character checksum. This is all outlined in the previously noted link and in the protocol specification here: https://www.telemessage.com/developer/wp-content/uploads/2014/11/TAP-1.8.pdf
Here is the part of the code giving me issues. I broke it out into just the checksum code:
$sum = 379 Write-Host “The sum is:” $sum -ForegroundColor cyan Write-host ‘The checksum should be “17;”‘`n $sum = [int]$sum $d3 = 48 + $sum – ([int]($sum / 16)) * 16 $sum = [int]($sum / 16) write-host “sum = $sum d3 = $d3” $d2 = 48 + $sum – ([int]($sum / 16)) * 16 $sum = [int]($sum / 16) write-host “sum = $sum d2 = $d2” $d1 = 48 + $sum – ([int]($sum / 16)) * 16 write-host “sum = $sum d1 = $d1” write-host ” : $d1 $d2 $d3″ $checksum =[string]([CHAR]$d1)+[string]([char]$d2)+[string]([char]$d3) write-host “Checksum : ” -ForegroundColor Yellow -NoNewline Write-host $checksum -ForegroundColor Cyan