Serial Receiver Control

Updated January 18, 2008


A common use of TSReader is to connect to a commercial receiver using interfaces like DVB-ASI or DVB-SPI. Many of these receivers have a built-in serial port that allows remote control over the receiver. When used with an appropriate TSReader source module, the receiver can be tuned using the standard tuner dialog that TSReader users see when using a PC connected demodulator like a PCI satellite card.

TSReader currently supports the following receivers and setup information is provided for each of them. If you have a receiver and you know the protocol to tune it you can develop your own serial control modules. If you do develop a module and would like other users to benefit from it, please get in touch. We provide source code for all our receiver control modules to use as a starting point.

Current Module List

To use a module, select a TSReader Source such as Linear Systems, Dektec or Alitronika, start TSReader and click on Settings/Serial Receiver Control, select the receiver type and the serial port it's connected to.

Motorola DSR-4800 By default, DSR-4800 receivers are setup with the RS-422 interface active. To select RS-232, remove the lid from the receiver and move the connector from the DB-9 to the connector on the ?? and turn the switch marked ? to ?. Once the receiver is powered back on, press the REMOTE button on the front panel and ensure ADDR=1000 and RS232-CFG is set to 9600-8N1.
Tandberg Alteia Plus Using the scroll wheels, go to menu 14 and select ?? to REMOTE
Newtec 2063 ?
Tandberg TT-1260 No idea!

Developing Modules

Serial receiver modules are Windows DLLs with a number of exported functions which TSReader will call. In turn, the TSReader_SourceHelper.dll has a number of functions of value to serial receiver control such as communicating over the serial port and handling the appropriate tuning dialog. In general to understand the operation of TSReader and it's source modules (the DLLs that read MPEG-2 TS from hardware) you should also read our documentation about how they work.

Serial receiver modules are located in the TSReader/Sources/ReceiverControl folder. DLLs are dynamically loaded/unloaded by TSReader as needed. For example, when TSReader displays the list of modules supported in the Settings/Serial Receiver Control dialog, it loads each of the DLLs to get the name of the device supported.

char * GetReceiverName()

This function tells TSReader the name of the receiver supported by the module. For example:

char * GetReceiverName()
  return "Motorola DSR-4800";

void GetSerialParameters(int *nBaudRate, int *nDataBits, int *nParity, int *nStopBits, BOOL *fDTR)

TSReader handles communicating with the serial port for you, but before it can open the port it needs the serial parameters. TSReader will call this function before it attempts to open the serial port. The values are pretty obvious -- the only special case is to return *nBaudRate as zero. In this case, TSReader won't actually open the serial port and is used when the module handles communications with the device by itself - for example when the connection is USB versus serial.

void GetSerialParameters(int *nBaudRate, int *nDataBits, int *nParity, int *nStopBits, BOOL *fDTR)
  *nBaudRate = 9600;
  *nDataBits = 8;
  *nParity = NOPARITY;
  *nStopBits = ONESTOPBIT;
  *fDTR = TRUE;

BOOL TuneReceiver(PSOURCESTRUCT ss, char * szTunerString)

This is the main function that actually tells the receiver to tune. In this routine you translate the values in the SOURCESTRUCT array into commands the receiver understands in order to tune and then inform the user if the receiver was able to obtain a lock. Since this function varies from receiver to receiver we suggest looking at the sample source code provided.

The szTunerString variable should be set by the module to indicate the tuner parameters. It's shown on the second line of the "General Information" display in the main TSReader window.

BOOL SetChannel(int nSID, int nTSID, int nNID)

This function gets called by TSReader when the user selects a channel in TSReader by either selecting a PMT entry in the tree-view or by clicking on a thumbnail. Receivers with conditional access for example would use this function to select the channel on the receiver which provided the receiver is authorized would cause that channel to be emitted on the ASI or SPI unscrambled.

nSID is the Service ID, nTSID is the Transport Stream ID and nNID is the Network ID which are obtained by TSReader as part of it's stream parsing.

SourceHelper Functions

TSReader's SourceHelper.dll exports a couple of functions used to communicate over the serial port:

SourceHelper_SendReceiverSerial(unsigned char * szString, int nLength)

This function sends the byte sequence pointed to by szString with nLength through the serial port. The function returns when all the characters have been sent.

BYTE SourceHelper_ReceiveReceiverSerial(int * nTimeout)

This function returns the next byte received on the serial interface. The nTimeout parameter contains the number of milliseconds to wait for a character before timing out. Typically the calling sequence for this function would be:

  int nTimeout = 1000;
  BYTE c = SourceHelper_ReceiveReceiverSerial(&nTimeout);
  if (nTimeout == 0)
  // Process character
} while (not_done);

Optional Module Entry Points

The entry points mentioned above are all required. Optionally, three other entry points are used by TSReader provided these are exported from the receiver control module. These are used to obtain the tuner signal strength and lock status while TSReader is running.

void StartSerial(PSOURCESTRUCT ss)

This routine is called just before TSReader starts it's incoming data threads, i.e. after the TunerReceiver() function has been called and returned TRUE. You'd use this call to start a thread that polls the receiver to get signal strength and lock.

void StopSerial(PSOURCESTRUCT ss)

The opposite of StartSerial(). This occurs when TSReader is shutting the input thread down. Use this call to stop the thread that's polling.

BOOL GetSignal(char * szSignal)

In this routine the DLLs returns the current signal status. This status is then displayed on the third line of the "General Status" area in TSReader's main window. Since this call happens asynchronously to the polling thread started when StartSerial() was called, it's worth protecting the global variable that contains the receiver status with a Windows Critical Section.

This routine is called at an approximate 1 Hz rate.