GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> CTDB / V5-5-6 > co1553_rt_sim / rhel5-32
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <CTDB/CO1553_rt_sim.h>
#include <CTDB/CO1553_util.h>
#include <CCSDS/CCSDS_pkt.h>
#include <CCSDS/CCSDS_swap.h>
#include <CCSDS/CCSDS_dump.h>
#include <PBS/FPA.h>
#include <PBS/MBA.h>
#include <PBS/RW.h>
#include <MSG/MSG_pubdefs.h>
#include <CO1553_rt_sim_private.h>
Functions | |
static unsigned int | CO1553_rtSimSockRead (int sock, unsigned char *buf, unsigned int size) |
static unsigned int | CO1553_rtSimSockWrite (int sock, unsigned char *buf, unsigned int size) |
Simulator Control Functions | |
unsigned int | CO1553_rtSimSizeof (void) |
Get the size of a remote terminal simulator descriptor. | |
CO1553_RT_Sim * | CO1553_rtSimGet (void) |
Get a pointer to the remote terminal simulator static descriptor. | |
unsigned int | CO1553_rtSimInit (CO1553_RT_Sim *rt, const CO1553_RT_Sim_Config *simConfig) |
Intialize a 1553 remote terminal simulator. | |
unsigned int | CO1553_rtSimExit (CO1553_RT_Sim *rt) |
Shutdown a 1553 remote terminal simulator. | |
unsigned int | CO1553_rtSimStart (CO1553_RT_Sim *rt) |
Start the remote terminal simulator listening for 1553 bus commands. | |
unsigned int | CO1553_rtSimStop (CO1553_RT_Sim *rt) |
Stop the remote terminal simulator listening for 1553 bus commands. | |
unsigned int | CO1553_rtSimHkpSet (CO1553_RT_Sim *rt, void *hkpHandler, void *hkpArg) |
Change the HKP application callback. | |
unsigned int | CO1553_rtSimHkpGet (CO1553_RT_Sim *rt, void **hkpHandler, void **hkpArg) |
Get current HKP application callback information. | |
Packet Queue Functions | |
unsigned int | CO1553_rtSimPktTelemSend (CO1553_RT_Sim *rt, void *pkt) |
Send a CCSDS telemetry packet. | |
unsigned int | CO1553_rtSimPktCmdRxRecv (CO1553_RT_Sim *rt, void **pkt) |
Receive a CCSDS telecommand receive packet. | |
unsigned int | CO1553_rtSimPktCmdRxFree (CO1553_RT_Sim *rt, void *pkt) |
Free a CCSDS telecommand receive packet buffer. | |
unsigned int | CO1553_rtSimPktCmdTxSend (CO1553_RT_Sim *rt, void *pkt) |
Send a CCSDS telecommand transmit packet. | |
Variables | |
static CO1553_RT_Sim | simDesc |
unsigned int CO1553_rtSimExit | ( | CO1553_RT_Sim * | rt | ) |
Shutdown a 1553 remote terminal simulator.
Disconnects the bus controller simulator and releases system resources claimed by the simulator.
rt | A device descriptor. |
References _CO1553_RT_Sim::check, _CO1553_RT_Sim::cmd_rx_fpa, _CO1553_RT_Sim::cmd_rx_pool, _CO1553_RT_Sim::cmd_rx_sock_listen, _CO1553_RT_Sim::cmd_tx_sock_listen, CO1553_rtSimStop(), _CO1553_RT_Sim::hkp_lock, and _CO1553_RT_Sim::telem_sock_listen.
Referenced by CTDB_rtExit().
CO1553_RT_Sim * CO1553_rtSimGet | ( | void | ) |
Get a pointer to the remote terminal simulator static descriptor.
Returns a pointer to a static instance of the simulator descriptor. This pointer may be passed in as the first paramter to all of the other simulator functions. CO1553_rtSimInit() must be called before use.
Referenced by CTDB_rtGet().
unsigned int CO1553_rtSimHkpGet | ( | CO1553_RT_Sim * | rt, | |
void ** | hkpHandler, | |||
void ** | hkpArg | |||
) |
Get current HKP application callback information.
Retrieves the HKP application callback function and arguments current values.
rt | A device descriptor. | |
hkpHandler | Stores the pointer to the application HKP function. | |
hkpArg | Stores user argument for hkpHandler. |
References _CO1553_RT_Sim::check, _CO1553_RT_Sim::hkp_arg, _CO1553_RT_Sim::hkp_handler, and _CO1553_RT_Sim::hkp_lock.
Referenced by CTDB_rtHkpGet().
unsigned int CO1553_rtSimHkpSet | ( | CO1553_RT_Sim * | rt, | |
void * | hkpHandler, | |||
void * | hkpArg | |||
) |
Change the HKP application callback.
Changes the HKP application callback function and arguments to new values (simulated).
rt | A device descriptor. | |
hkpHandler | The callback to handle insertion of HKP telemety. | |
hkpArg | A user argument for hkpHandler. |
References _CO1553_RT_Sim::check, _CO1553_RT_Sim::hkp_arg, _CO1553_RT_Sim::hkp_handler, and _CO1553_RT_Sim::hkp_lock.
Referenced by CTDB_rtHkpSet().
unsigned int CO1553_rtSimInit | ( | CO1553_RT_Sim * | rt, | |
const CO1553_RT_Sim_Config * | simConfig | |||
) |
Intialize a 1553 remote terminal simulator.
Intializes the remote terminal simulator descriptor and simlator software.
rt | An uninitialized simlator descriptor. | |
simConfig | The configuration values for the simulator. |
References _CO1553_RT_Sim::check, _CO1553_RT_Sim::cmd_rx_fpa, _CO1553_RT_Sim_Config::cmd_rx_pkt_size, _CO1553_RT_Sim::cmd_rx_pool, _CO1553_RT_Sim_Config::cmd_rx_port, _CO1553_RT_Sim_Config::cmd_rx_queue_size, _CO1553_RT_Sim::cmd_rx_sock_listen, _CO1553_RT_Sim_Config::cmd_rx_user_size, _CO1553_RT_Sim_Config::cmd_tx_pkt_size, _CO1553_RT_Sim_Config::cmd_tx_port, _CO1553_RT_Sim::cmd_tx_sock_listen, _CO1553_RT_Sim::hdr_size_cmd, _CO1553_RT_Sim::hdr_size_telem, _CO1553_RT_Sim::hkp_arg, _CO1553_RT_Sim::hkp_handler, _CO1553_RT_Sim::hkp_lock, _CO1553_RT_Sim::sim_config, _CO1553_RT_Sim_Config::telem_pkt_size, _CO1553_RT_Sim_Config::telem_port, and _CO1553_RT_Sim::telem_sock_listen.
unsigned int CO1553_rtSimPktCmdRxFree | ( | CO1553_RT_Sim * | rt, | |
void * | pkt | |||
) |
Free a CCSDS telecommand receive packet buffer.
Returns a telecommand receive packet buffer to the simulator.
rt | A device descriptor. | |
pkt | The telecommand packet buffer. |
References _CO1553_RT_Sim::check, _CO1553_RT_Sim::cmd_rx_fpa, _CO1553_RT_Sim_Config::cmd_rx_user_size, and _CO1553_RT_Sim::sim_config.
Referenced by CTDB_rtPktCmdRxFree().
unsigned int CO1553_rtSimPktCmdRxRecv | ( | CO1553_RT_Sim * | rt, | |
void ** | pkt | |||
) |
Receive a CCSDS telecommand receive packet.
Waits for a new CCSDS telecommand receive packet on the remote terminal input queue. The function will place a pointer to the new packet in pkt. Call CO1553_rtSimPktCmdRxFree() to return the packet buffer to the simulator.
rt | A device descriptor. | |
pkt | Holds a pointer to the received telecommand packet buffer. |
References _CO1553_RT_Sim::check, _CO1553_RT_Sim::cmd_rx_fpa, _CO1553_RT_Sim_Config::cmd_rx_pkt_size, _CO1553_RT_Sim::cmd_rx_sock_data, _CO1553_RT_Sim_Config::cmd_rx_user_size, CO1553_MSG_SIZE, CO1553_rtSimSockRead(), _CO1553_RT_Sim::hdr_size_cmd, and _CO1553_RT_Sim::sim_config.
Referenced by CTDB_rtPktCmdRxRecv().
unsigned int CO1553_rtSimPktCmdTxSend | ( | CO1553_RT_Sim * | rt, | |
void * | pkt | |||
) |
Send a CCSDS telecommand transmit packet.
Places a CCSDS telecommand packet on the remote terminal output queue. The packet will be sent when bandwidth becomes available.
rt | A simultator descriptor. | |
pkt | A pointer to the packet to send. The packet buffer should start with a properly formatted CCSDS packet header. |
References _CO1553_RT_Sim::check, _CO1553_RT_Sim_Config::cmd_tx_pkt_size, _CO1553_RT_Sim::cmd_tx_sock_data, CO1553_MSG_SIZE, CO1553_rtSimSockWrite(), _CO1553_RT_Sim::hdr_size_cmd, and _CO1553_RT_Sim::sim_config.
Referenced by CTDB_rtPktCmdTxSend().
unsigned int CO1553_rtSimPktTelemSend | ( | CO1553_RT_Sim * | rt, | |
void * | pkt | |||
) |
Send a CCSDS telemetry packet.
Places a CCSDS telemetry packet on the remote terminal output queue. The packet will be sent when bandwidth becomes available.
rt | A simultator descriptor. | |
pkt | A pointer to the packet to send. The packet buffer should start with a properly formatted CCSDS packet header. |
References _CO1553_RT_Sim::check, CO1553_MSG_SIZE, CO1553_rtSimSockWrite(), _CO1553_RT_Sim::hdr_size_telem, _CO1553_RT_Sim::sim_config, _CO1553_RT_Sim_Config::telem_pkt_size, and _CO1553_RT_Sim::telem_sock_data.
Referenced by CTDB_rtPktTelemSend().
unsigned int CO1553_rtSimSizeof | ( | void | ) |
Get the size of a remote terminal simulator descriptor.
Returns the size of a Summit remote terminal simulator descriptor. The user is responsible for allocating this memory before calling SUMT_rtSimInit().
This function is obsolete. Use CO1553_rtSimGet() to provide an instance of the simulator descriptor instead.
Referenced by CTDB_rtSizeof().
static unsigned int CO1553_rtSimSockRead | ( | int | sock, | |
unsigned char * | buf, | |||
unsigned int | size | |||
) | [static] |
Reads a packet buffer from a socket.
sock | The socket to write to. | |
buf | The packet buffer. | |
size | The packet size. |
Referenced by CO1553_rtSimPktCmdRxRecv().
static unsigned int CO1553_rtSimSockWrite | ( | int | sock, | |
unsigned char * | buf, | |||
unsigned int | size | |||
) | [static] |
Writes a packet buffer to a socket.
sock | The socket to write to. | |
buf | The packet buffer. | |
size | The packet size. |
Referenced by CO1553_rtSimPktCmdTxSend(), and CO1553_rtSimPktTelemSend().
unsigned int CO1553_rtSimStart | ( | CO1553_RT_Sim * | rt | ) |
Start the remote terminal simulator listening for 1553 bus commands.
Starts the remote terminal listening on the 1553 bus for commands from the bus controller. For the simulator, the remote terminal TCP server listens for connections on the subaddress sockets.
rt | A simultator descriptor. |
References _CO1553_RT_Sim::check, _CO1553_RT_Sim::cmd_rx_sock_data, _CO1553_RT_Sim::cmd_rx_sock_listen, _CO1553_RT_Sim::cmd_tx_sock_data, _CO1553_RT_Sim::cmd_tx_sock_listen, _CO1553_RT_Sim::telem_sock_data, and _CO1553_RT_Sim::telem_sock_listen.
Referenced by CTDB_rtStart().
unsigned int CO1553_rtSimStop | ( | CO1553_RT_Sim * | rt | ) |
Stop the remote terminal simulator listening for 1553 bus commands.
Stops the remote terminal listening on the 1553 bus for commands from the bus controller. For the simulator, the remote terminal TCP server disconnects the subaddress sockets.
rt | A simultator descriptor. |
References _CO1553_RT_Sim::check, _CO1553_RT_Sim::cmd_rx_sock_data, _CO1553_RT_Sim::cmd_tx_sock_data, and _CO1553_RT_Sim::telem_sock_data.
Referenced by CO1553_rtSimExit(), and CTDB_rtStop().
simDesc [static] |
An instance of the simulator descriptor; used for CO1553_bcSimGet().