insat INSAT custom formatting utility routines

insat.py

These functions are meant to allow full flexibility in formatting an INSAT message.

  • One must be familiar with the data content of an INSAT transmission.
  • Please see insat_test.py for tests and additional illustrations.
insat.bit_write(msg, position, set)

Sets or clears the bit in the specified position of the INSAT message

Parameters:
  • msg – this is the 25 byte (199 bit) bytestring that is the insat message
  • position – bit position in msg where to encode the value. time starts at bit 0, C1 at bit 5
  • set – bool indicating whether to set or clear the bit
insat.even_parity_bits(num, bits)

Computes even parity on the provided int Only said number of bits are computed

Parameters:
  • num – number whose parity should be computed
  • bits – number of relevant bits in num to compute parity on
Returns:

1 if parity bit should be set to 1, 0 otherwise

Return type:

int

insat.insat_10_bit(val)

Converts provided sensor or calibration reading into a 10 bit number Rounds down the provided value If value is out of range, it gets set to 0 or 1023

Parameters:val (float) – sensor or cal reading
Returns:10 bit integer
insat.insat_a1(standard)

custom formatting routine shows how to create a fixed insat message

insat.insat_a2(standard)

custom formatting routine shows how to create a new message

insat.insat_a2_two_msg(standard)

This custom formatting routine prepares two different messages The first 25 bytes (bytes 0 to 24) have the first message The second 25 bytes (bytes 25 to 49) are for the second message INSAT TDMA sends two transmissions. If there are two different messages, each is sent. If not, the same message is repeated twice.

insat.insat_a3(standard)

This custom formatting routine illustrates how to create a complete custom INSAT message

insat.insat_encode_data(time_hours, health, cal, sensor)

Encodes the whole INSAT message

Parameters:
  • time_hours – time of transmission in hours, int
  • health – 10 bits of health info, int
  • cal – three values for calibration data
  • sensor – 10 sensor values, S1 through S10
Returns:

encoded INSAT msg as a bytearray

insat.insat_encode_val(msg, val, position, bits, add_parity)

Encodes the provided value into the INSAT message For S1, S2.. S10 and C1, C2, C3, the number of bits should be set to 10, parity enabled

Parameters:
  • msg – this is the 25 byte (199 bit) bytestring that is the insat message
  • val – the value to encode (int)
  • position – bit position in msg where to encode the value. time starts at bit 0, C1 at bit 5
  • bits – how many bits of the value to encode
  • add_parity – a bool indicating whether to add a parity bit
Returns:

position moved forward by bits and parity

Return type:

int