I wrote a program called scanner screen for uniden scanners I would like to add whistler scanners

Vonskie

Member
Joined
Feb 7, 2005
Messages
521
Location
Allen, TX
Any one have any idea where I can get a list of commands you can send to the scanner via the serial interface and what it returns?

latest.png
 

fxdscon

¯\_(ツ)_/¯
Premium Subscriber
Joined
Jan 15, 2007
Messages
7,495
Any one have any idea where I can get a list of commands you can send to the scanner via the serial interface and what it returns?

Anything useful here?

 

RaleighGuy

Member
Premium Subscriber
Joined
Jul 15, 2014
Messages
16,041
Location
Raleigh, NC
Any one have any idea where I can get a list of commands you can send to the scanner via the serial interface and what it returns?

Maybe this PDF I attached. Have you seen TRX Android Suite? Maybe that will give you some ideas or you can reach out to the.
 

Attachments

  • Whistler Remote Control Protocol v1.6.pdf
    109.5 KB · Views: 25
Last edited:

Vonskie

Member
Joined
Feb 7, 2005
Messages
521
Location
Allen, TX
Very cool
I would like you to run a test program on your scanner trx-1-2 etc and see if it works.

I will complie a simple program and you can tell me if it grabs the info from the scanner.

I had AI read the reference PDF and build the code for me with prompting.



program WhistlerRemoteControl;

uses
SysUtils, Math, synaser;

const
STX = #2;
ETX = #3;
SERIAL_PORT_NAME = 'COM1'; // Replace with your serial port name
TIMEOUT_MS = 1000; // Timeout in milliseconds

type
TRecordingType = (rtConventional, rtTalkgroup, rtSearch);

TStm = packed record
tm_sec: SmallInt;
tm_min: SmallInt;
tm_hour: SmallInt;
tm_mday: SmallInt;
tm_mon: SmallInt;
tm_year: SmallInt;
tm_wday: SmallInt;
tm_yday: SmallInt;
tm_isdst: SmallInt;
end;

TAudioFileHeader = packed record
MagicNumber: Cardinal;
AudioDataOffset: Cardinal;
AudioDataSize: Cardinal;
EncodingFormat: Cardinal;
SampleRate: Cardinal;
ChannelCount: Cardinal;
RecordingType: Byte;
StartTime: TStm;
ObjectAlphaTag: array[0..16] of Char;
TrunkedSystemAlphaTag: array[0..16] of Char;
InfoAlphaTag: array[0..16] of Char;
ObjectID: Cardinal;
TalkgroupID1: Cardinal;
TalkgroupID2: Cardinal;
RadioID1: Cardinal;
RadioID2: Cardinal;
SiteName: array[0..16] of Char;
TSYSFileIndex: Cardinal;
MiscInfo: array[0..16] of Char;
VoiceFrequency: Cardinal;
ControlChannelFrequency: Cardinal;
SquelchMode: Word;
SquelchValue: Word;
TSYSType: Byte;
Reserved: array[0..154] of Byte;
end;

var
SerialPort: TBlockSerial;
ModelNumber: string;
ChannelInfo: string;
AudioHeader: TAudioFileHeader;

function CalculateChecksum(const Data: string): Byte;
var
i: Integer;
Sum: Byte;
begin
Sum := 0;
for i := 1 to Length(Data) do
Sum := Sum + Ord(Data);
Result := Sum and $FF;
end;

function CreateCommand(const MsgCode: Char; const MsgData: string): string;
var
Command: string;
begin
Command := STX + MsgCode + MsgData + ETX;
Command := Command + Chr(CalculateChecksum(Command));
Result := Command;
end;

function SendCommand(const Command: string): Boolean;
begin
Result := False;
try
SerialPort.SendString(Command);
SerialPort.WaitForTx(TIMEOUT_MS);
Result := True;
except
on E: Exception do
begin
WriteLn('Error sending command: ' + E.Message);
end;
end;
end;

function ReceiveResponse: string;
var
Response: string;
Data: Char;
begin
Response := '';
try
repeat
SerialPort.RecvString(Data, 1);
Response := Response + Data;
until (Data = ETX) or (SerialPort.LastError <> 0);
if CalculateChecksum(Response) = Ord(Response[Length(Response)]) then
Result := Response
else
Result := '';
except
on E: Exception do
begin
WriteLn('Error receiving response: ' + E.Message);
Result := '';
end;
end;
end;

procedure CloseSerialPort;
begin
SerialPort.CloseSocket;
SerialPort.Free;
end;

procedure GetModelNumber;
var
Command, Response: string;
begin
Command := CreateCommand('V', #0);
if SendCommand(Command) then
begin
Response := ReceiveResponse;
if (Length(Response) >= 14) and (Response[2] = 'V') then
begin
ModelNumber := Copy(Response, 4, 8);
WriteLn('Model Number: ', ModelNumber);
end
else
WriteLn('Invalid response for model number');
end
else
WriteLn('Failed to send command for model number');
end;

procedure GetChannelInfo;
var
Command, Response: string;
i, Len: Integer;
begin
Command := CreateCommand('a', '');
if SendCommand(Command) then
begin
Response := ReceiveResponse;
if (Length(Response) >= 8) and (Response[2] = 'a') then
begin
Len := Ord(Response[4]) * 256 + Ord(Response[5]);
if Len > 0 then
begin
ChannelInfo := Copy(Response, 6, Len);
WriteLn('Channel Info: ', ChannelInfo);

// Extract audio file header information
Move(ChannelInfo[1], AudioHeader, SizeOf(AudioHeader));

// Extract individual fields from the audio file header
WriteLn('Magic Number: ', AudioHeader.MagicNumber);
WriteLn('Audio Data Offset: ', AudioHeader.AudioDataOffset);
WriteLn('Audio Data Size: ', AudioHeader.AudioDataSize);
WriteLn('Encoding Format: ', AudioHeader.EncodingFormat);
WriteLn('Sample Rate: ', AudioHeader.SampleRate);
WriteLn('Channel Count: ', AudioHeader.ChannelCount);
WriteLn('Recording Type: ', Ord(AudioHeader.RecordingType));
WriteLn('Start Time:');
WriteLn(' Year: ', AudioHeader.StartTime.tm_year + 1900);
WriteLn(' Month: ', AudioHeader.StartTime.tm_mon + 1);
WriteLn(' Day: ', AudioHeader.StartTime.tm_mday);
WriteLn(' Hour: ', AudioHeader.StartTime.tm_hour);
WriteLn(' Minute: ', AudioHeader.StartTime.tm_min);
WriteLn(' Second: ', AudioHeader.StartTime.tm_sec);
WriteLn('Object Alpha Tag: ', AudioHeader.ObjectAlphaTag);
WriteLn('Trunked System Alpha Tag: ', AudioHeader.TrunkedSystemAlphaTag);
WriteLn('Info Alpha Tag: ', AudioHeader.InfoAlphaTag);
WriteLn('Object ID: ', AudioHeader.ObjectID);
WriteLn('Talkgroup ID 1: ', AudioHeader.TalkgroupID1);
WriteLn('Talkgroup ID 2: ', AudioHeader.TalkgroupID2);
WriteLn('Radio ID 1: ', AudioHeader.RadioID1);
WriteLn('Radio ID 2: ', AudioHeader.RadioID2);
WriteLn('Site Name: ', AudioHeader.SiteName);
WriteLn('TSYS File Index: ', AudioHeader.TSYSFileIndex);
WriteLn('Misc Info: ', AudioHeader.MiscInfo);
WriteLn('Voice Frequency: ', AudioHeader.VoiceFrequency);
WriteLn('Control Channel Frequency: ', AudioHeader.ControlChannelFrequency);
WriteLn('Squelch Mode: ', AudioHeader.SquelchMode);
WriteLn('Squelch Value: ', AudioHeader.SquelchValue);
WriteLn('TSYS Type: ', AudioHeader.TSYSType);
end
else
WriteLn('No active channel');
end
else
WriteLn('Invalid response for channel info');
end
else
WriteLn('Failed to send command for channel info');
end;

begin
SerialPort := TBlockSerial.Create;
try
// Open the serial port
SerialPort.Connect(SERIAL_PORT_NAME);
SerialPort.Config(115200, 8, 'N', 1, False, False);

// Get model number
GetModelNumber;

// Get channel info
GetChannelInfo;

// Add more commands and processing as needed

except
on E: Exception do
begin
WriteLn('Error: ' + E.Message);
end;
end;

// Close the serial port when the program is complete
CloseSerialPort;
end.
 

Vonskie

Member
Joined
Feb 7, 2005
Messages
521
Location
Allen, TX
I had some kind of crash when experimenting with forcing the application to hide and popup on activity and tried many different calls. It works best using application.Minimize and form1.WindowState:= wsnormal as it doesn't force itself on top of other windows you could be actively working on.

I started over and instead modified the 2.671 version. I'm just doing an indexed delimited fetch from the received data from a TRX scanner for the model, frequency and its text tag, and the TRX-1 has it's received frequency index one step earlier than TRX-2, so have to check if the frequency is blank and then fetch from the index before that. I have to read up on how to fetch from specific addresses in a received data block and then I could also pick modulation types and everything else.

I added support for a UBC780 and in remote mode it responds sluggish from front panel operations so it's really struggling. Sometimes it has a hickup and only responds with garbage in the raw data box from a status request and needs to be switched off and on to clear its communications. I'll check if it's any different using 2400 speed but it behaves the same in 19200 as in 4800.

The BCD536 still dropped connections but using the rear RS232 port makes it run without any issues.

I'll need another USB hub and a couple of more USB to Serial cables.

I don't know how many copies of the application that can be run as the 5:th copy couldn't communicate with the scanner what ever I did with comports, cables and different scanners. Then I tried an earlier version of the application and that worked. But after that the new version also started to work to do a 5:th and also a 6:th a 7:th and 8:th scanner connection.

Scanner-Screen4.jpg


/Ubbe
Check this out
 

Attachments

  • Whistler Remote Control Protocol v1.6 (1).pdf
    109.5 KB · Views: 14

Vonskie

Member
Joined
Feb 7, 2005
Messages
521
Location
Allen, TX
I had some kind of crash when experimenting with forcing the application to hide and popup on activity and tried many different calls. It works best using application.Minimize and form1.WindowState:= wsnormal as it doesn't force itself on top of other windows you could be actively working on.

I started over and instead modified the 2.671 version. I'm just doing an indexed delimited fetch from the received data from a TRX scanner for the model, frequency and its text tag, and the TRX-1 has it's received frequency index one step earlier than TRX-2, so have to check if the frequency is blank and then fetch from the index before that. I have to read up on how to fetch from specific addresses in a received data block and then I could also pick modulation types and everything else.

I added support for a UBC780 and in remote mode it responds sluggish from front panel operations so it's really struggling. Sometimes it has a hickup and only responds with garbage in the raw data box from a status request and needs to be switched off and on to clear its communications. I'll check if it's any different using 2400 speed but it behaves the same in 19200 as in 4800.

The BCD536 still dropped connections but using the rear RS232 port makes it run without any issues.

I'll need another USB hub and a couple of more USB to Serial cables.

I don't know how many copies of the application that can be run as the 5:th copy couldn't communicate with the scanner what ever I did with comports, cables and different scanners. Then I tried an earlier version of the application and that worked. But after that the new version also started to work to do a 5:th and also a 6:th a 7:th and 8:th scanner connection.

Scanner-Screen4.jpg


/Ubbe
I don't know how many copies of the application that can be run as the 5:th copy couldn't communicate with the scanner what ever I did with comports, cables and different scanners. Then I tried an earlier version of the application and that worked. But after that the new version also started to work to do a 5:th and also a 6:th a 7:th and 8:th scanner connection.
Intresting I never ran more than one instance. The program runs in its own instance so as long as windows can give it a good virtual serial connection it should run as many copies as windows allows. Maybe slow down the rate to 9600 not sure.
 

Vonskie

Member
Joined
Feb 7, 2005
Messages
521
Location
Allen, TX
I had some kind of crash when experimenting with forcing the application to hide and popup on activity and tried many different calls. It works best using application.Minimize and form1.WindowState:= wsnormal as it doesn't force itself on top of other windows you could be actively working on.

I started over and instead modified the 2.671 version. I'm just doing an indexed delimited fetch from the received data from a TRX scanner for the model, frequency and its text tag, and the TRX-1 has it's received frequency index one step earlier than TRX-2, so have to check if the frequency is blank and then fetch from the index before that. I have to read up on how to fetch from specific addresses in a received data block and then I could also pick modulation types and everything else.

I added support for a UBC780 and in remote mode it responds sluggish from front panel operations so it's really struggling. Sometimes it has a hickup and only responds with garbage in the raw data box from a status request and needs to be switched off and on to clear its communications. I'll check if it's any different using 2400 speed but it behaves the same in 19200 as in 4800.

The BCD536 still dropped connections but using the rear RS232 port makes it run without any issues.

I'll need another USB hub and a couple of more USB to Serial cables.

I don't know how many copies of the application that can be run as the 5:th copy couldn't communicate with the scanner what ever I did with comports, cables and different scanners. Then I tried an earlier version of the application and that worked. But after that the new version also started to work to do a 5:th and also a 6:th a 7:th and 8:th scanner connection.

Scanner-Screen4.jpg


/Ubbe
Can you please do me a favor I put together a small program to test the whistler

Its the whistlertest.exe please download it and run it
Select the com port
Click connect
Click Get Model
Click get channel info
Let me know the results
I do not have a whistler to test with.
The source code is also listed in the whistlertest dir
 

Vonskie

Member
Joined
Feb 7, 2005
Messages
521
Location
Allen, TX
Can you please do me a favor I put together a small program to test the whistler

Its the whistlertest.exe please download it and run it
Select the com port
Click connect
Click Get Model
Click get channel info
Let me know the results
I do not have a whistler to test with.
The source code is also listed in the whistlertest dir
I had AI read the reference manual then build the program for the most part then I had to fix the things it got wrong.
Hopefully its close enough to give some results.
 

Wackyracer

Member
Premium Subscriber
Joined
Feb 18, 2016
Messages
1,956
file:///C:/Users/Dan/Downloads/Whistler%20Remote%20Control%20Protocol%20v1.6.pdf
 

RaleighGuy

Member
Premium Subscriber
Joined
Jul 15, 2014
Messages
16,041
Location
Raleigh, NC
I had AI read the reference manual then build the program for the most part then I had to fix the things it got wrong.
Hopefully its close enough to give some results.

Not sure if I'm doing it right or not, tried with PC/IF Dump on and off, it is connected and on an active channel/TG/system but continue to get errors and doesn't show anything. Using Win 10.

Screenshot for CONNECT....GET RADIO...GET CHANNEL

3.JPG2.JPG1.JPG
 
Last edited:

Vonskie

Member
Joined
Feb 7, 2005
Messages
521
Location
Allen, TX

Vonskie

Member
Joined
Feb 7, 2005
Messages
521
Location
Allen, TX
Top