Skip to main content

Description of function libraries in C

The functions described below are used to interact with subsystems when writing programs for the OrbiCraft satellite designer in the language C.

note

For devices whose number is not indicated on the case, the default number is used 1 .

note

Standard codes returned by library functions:

#define LSS_OK 0

#define LSS_ERROR 1

#define LSS_BREAK 2

Power Supply System (PSS)

float battery_get_charge(void);

Returns the current charge of the virtual PSS (mAh)

float battery_get_discharging_current(void);

Returns the current discharge current PSS (mA)

Magnetometer

int magnetometer_get_state(uint16_t num);

Returns the current state of the magnetometer (on/off)

int magnetometer_request_raw(uint16_t num,int16_t *pRAW_dataX,int16_t *pRAW_dataY,int16_t *pRAW_dataZ); 

Returns LSS_OK and records the current magnetometer readings with the number num in the variables pRAW_dataX - pRAW_dataZ

info

In case of errors on the bus, returns LSS_ERROR;

If there is no power on the magnetometer, it returns LSS_BREAK;

The return value contains: - 1100 RAW units per Gauss on the X and Y axes, 980 RAW units per Gauss on the Z axis.

int magnetometer_request_reset(uint16_t num); 

Restarts the magnetometer number num

int magnetometer_turn_off(uint16_t num);

Turns off the magnetometer number num

int magnetometer_turn_on(uint16_t num);

Includes magnetometer number num

Angular Velocity Sensor (AVS)

int hyro_get_state(uint16_t num);

Returns the current AVS status (on/off)

int hyro_request_raw(uint16_t num,int16_t *pRAW_dataX,int16_t *pRAW_dataY,int16_t *pRAW_dataZ); 

Returns LSS_OK and writes the current AVS readings with the number num to the variables pRAW_dataX - pRAW_dataZ.

info

In case of errors on the bus, returns LSS_ERROR;

If there is no power on the AVS, it returns LSS_BREAK;

The angular velocity determined by the sensor is 0.00875 degrees/second per RAW unit.

int hyro_request_reset(uint16_t num);

Resets the AVS number num

int hyro_turn_off(uint16_t num);

Turns off the AVS number num

int hyro_turn_on(uint16_t num);

Includes AVS number num

Solar sensor

int sun_sensor_get_state(uint16_t num);

Returns the current state of the solar sensor number num (on/off)

int sun_sensor_request_maxraw(uint16_t num, uint16_t *pMAXRAW_data1, uint16_t *pMAXRAW_data2); 

Returns LSS_OK and records the current maximum readings of the solar sensor sensors with the number num in the variables pMAXRAW_data1 and pMAXRAW_data2. Maximum - the maximum reading that the sensor has ever detected since the reboot

info

In case of errors on the bus, returns LSS_ERROR;

If there is no power on the solar sensor, it returns LSS_BREAK.

int sun_sensor_request_raw(uint16_t num, uint16_t *pRAW_data1, uint16_t *pRAW_data2); 

Returns LSS_OK and records the current readings of the solar sensor sensors with the number num in the variables pRAW_data1 and pRAW_data2.

info

In case of errors on the bus, returns LSS_ERROR;

If there is no power on the solar sensor, it returns LSS_BREAK.

int sun_sensor_request_reset(uint16_t num);

Resets the solar sensor number num

int sun_sensor_set_calibrate(uint16_t num,uint8_t mode);

Not used

int sun_sensor_set_minvalue(uint16_t num,uint16_t value); 

Not used

int sun_sensor_turn_off(uint16_t num);

Turns off the solar sensor number num

int sun_sensor_turn_on(uint16_t num);

Includes solar sensor number num

Flywheel engine

int motor_get_state(uint16_t num);

Returns the current state of the flywheel number num (on/off)

int motor_request_reset(uint16_t num);

Resets the flywheel number num

int motor_request_speed(uint16_t num,int16_t *pRPM);

Returns LSS_OK and writes the current speed of the flywheel with the number num to the variable pRPM

info

In case of errors on the bus, returns LSS_ERROR;

If there is no power on the flywheel, it returns LSS_BREAK.

int motor_set_speed(uint16_t num,int16_t RPM,int16_t *confirm);

Returns LSS_OK and writes the set speed for the flywheel with the number num to the variable confirm, sets this speed to the flywheel

info

In case of errors on the bus, returns LSS_ERROR;

If there is no power on the flywheel, it returns LSS_BREAK.

int motor_turn_off(uint16_t num);

Turns off the flywheel with the num number (short-term shutdown and activation is not recommended!)

int motor_turn_on(uint16_t num);

Includes a flywheel with the number num

ERS Camera

int camera_get_state(void); 

Returns the current state of the camera (on/off)

int camera_turn_off(void);

Turns off the camera

int camera_turn_on(void);

Turns on the camera

int camera_take_photo(uint16_t num);

Takes a photo with the camera in the cell with the number num

HF radio channel

int transmitter_get_state(uint16_t num);

Returns the current state of the HF transmitter (on/off)

int transmitter_transmit_photo(uint16_t num, uint16_t nPhoto);

Transmits a photo from the camera cell nPhoto number using the HF transmitter num number to the HF receiver (to the Ground)

int transmitter_request_reset(uint16_t num);

Resets the HF transmitter number num

int transmitter_turn_off(uint16_t num);

Turns off the HF transmitter number num

int transmitter_turn_on(uint16_t num);

Includes HF transmitter number num

UHF radio channel

int transceiver_get_state(uint16_t num);

Returns the current status of the telemetry transmitter num number (on/off)

int transceiver_request_buff(uint16_t num,uint8_t *data);

Not used

int transceiver_request_reset(uint16_t num);

Restarts the telemetry transmitter number num

int transceiver_send(uint16_t tx_num,uint16_t rx_num,const uint8_t *data,uint16_t len);

Sends a data packet with data of length len from the telemetry transmitter tx_num number to the address of the telemetry receiver rx_num number (to the ground)

int transceiver_turn_off(uint16_t num);

Turns off the NUM telemetry transmitter to reduce power consumption

int transceiver_turn_on(uint16_t num);

Turns on the telemetry transmitter number num

General functions

void dump_buffer(uint8_t *buf,size_t len);

Not used

void mSleep(int msec);

Pause in the program for msec milliseconds

void Sleep(int sec);

Pause in the program for sec seconds

int bus_setup(void);

Prepares all devices on the bus to receive information. By default, devices after switching on or rebooting can start exchanging only after completing at least one package on the bus (for any device), this function simply sends an empty message addressed to everyone.