GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> CTDB / V5-5-6 > co1553_bc_sim / rhel6-64
#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_bc_sim.h>
#include <CTDB/CO1553_util.h>
#include <CCSDS/CCSDS_pkt.h>
#include <CCSDS/CCSDS_swap.h>
#include <PBS/FPA.h>
#include <PBS/MBA.h>
#include <MSG/MSG_pubdefs.h>
#include <CO1553_bc_sim_private.h>
Functions | |
static unsigned int | CO1553_bcSimSockRead (int sock, unsigned char *buf, unsigned int size) |
static unsigned int | CO1553_bcSimSockWrite (int sock, unsigned char *buf, unsigned int size) |
Simulator Control Functions | |
unsigned int | CO1553_bcSimSizeof (void) |
Get the size of a bus controller simulator descriptor. | |
CO1553_BC_Sim * | CO1553_bcSimGet (void) |
Get a pointer to the bus controller simulator static descriptor. | |
unsigned int | CO1553_bcSimInit (CO1553_BC_Sim *bc, const CO1553_BC_Sim_Config *simConfig, const char *rtAddr) |
Intialize a 1553 bus controller simulator. | |
unsigned int | CO1553_bcSimExit (CO1553_BC_Sim *bc) |
Shutdown a 1553 bus controller simulator. | |
unsigned int | CO1553_bcSimStart (CO1553_BC_Sim *bc) |
Start the bus controller simulator sending 1553 bus commands. | |
unsigned int | CO1553_bcSimStop (CO1553_BC_Sim *bc) |
Stop the bus controller simulator sending 1553 bus commands. | |
Packet Queue Functions | |
unsigned int | CO1553_bcSimPktCmdRxSend (CO1553_BC_Sim *bc, void *pkt) |
Send a CCSDS telecommand receive packet. | |
unsigned int | CO1553_bcSimPktTelemRecv (CO1553_BC_Sim *bc, void **pkt) |
Receive a CCSDS telemetry packet. | |
unsigned int | CO1553_bcSimPktTelemFree (CO1553_BC_Sim *bc, void *pkt) |
Free a CCSDS telemetry packet buffer. | |
unsigned int | CO1553_bcSimPktCmdTxRecv (CO1553_BC_Sim *bc, void **pkt) |
Receive a CCSDS telecommand transmit packet. | |
unsigned int | CO1553_bcSimPktCmdTxFree (CO1553_BC_Sim *bc, void *pkt) |
Free a CCSDS telecommand transmit packet buffer. | |
Variables | |
static CO1553_BC_Sim | simDesc |
unsigned int CO1553_bcSimExit | ( | CO1553_BC_Sim * | bc | ) |
Shutdown a 1553 bus controller simulator.
Disconnects the bus controller simulator and releases system resources claimed by the simulator.
bc | A device descriptor. |
References _CO1553_BC_Sim::check, _CO1553_BC_Sim::cmd_tx_fpa, _CO1553_BC_Sim::cmd_tx_pool, CO1553_bcSimStop(), _CO1553_BC_Sim::telem_fpa, and _CO1553_BC_Sim::telem_pool.
Referenced by CTDB_bcExit().
CO1553_BC_Sim * CO1553_bcSimGet | ( | void | ) |
Get a pointer to the bus controller 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_bcSimInit() must be called before use.
Referenced by CTDB_bcGet().
unsigned int CO1553_bcSimInit | ( | CO1553_BC_Sim * | bc, | |
const CO1553_BC_Sim_Config * | simConfig, | |||
const char * | rtAddr | |||
) |
Intialize a 1553 bus controller simulator.
Intializes the bus controller simulator descriptor and simlator software.
bc | An uninitialized simlator descriptor. | |
simConfig | The configuration values for the simulator. | |
rtAddr | The name or dot numerical IP address of the RT simulator node. |
References _CO1553_BC_Sim::check, _CO1553_BC_Sim_Config::cmd_rx_pkt_size, _CO1553_BC_Sim_Config::cmd_rx_port, _CO1553_BC_Sim::cmd_tx_fpa, _CO1553_BC_Sim_Config::cmd_tx_pkt_size, _CO1553_BC_Sim::cmd_tx_pool, _CO1553_BC_Sim_Config::cmd_tx_port, _CO1553_BC_Sim_Config::cmd_tx_queue_size, _CO1553_BC_Sim::hdr_size_cmd, _CO1553_BC_Sim::hdr_size_telem, _CO1553_BC_Sim::rt_addr, _CO1553_BC_Sim::sim_config, _CO1553_BC_Sim::telem_fpa, _CO1553_BC_Sim_Config::telem_pkt_size, _CO1553_BC_Sim::telem_pool, _CO1553_BC_Sim_Config::telem_port, and _CO1553_BC_Sim_Config::telem_queue_size.
unsigned int CO1553_bcSimPktCmdRxSend | ( | CO1553_BC_Sim * | bc, | |
void * | pkt | |||
) |
Send a CCSDS telecommand receive packet.
Places a CCSDS telecommand receive packet on the bus controller output queue. The packet will be sent when bandwidth becomes available.
bc | A device descriptor. | |
pkt | A pointer to the packet to send. The packet buffer should start with a properly formatted CCSDS packet header. |
References _CO1553_BC_Sim::check, _CO1553_BC_Sim_Config::cmd_rx_pkt_size, _CO1553_BC_Sim::cmd_rx_sock, CO1553_bcSimSockWrite(), CO1553_MSG_SIZE, _CO1553_BC_Sim::hdr_size_cmd, and _CO1553_BC_Sim::sim_config.
Referenced by CTDB_bcPktCmdRxSend().
unsigned int CO1553_bcSimPktCmdTxFree | ( | CO1553_BC_Sim * | bc, | |
void * | pkt | |||
) |
Free a CCSDS telecommand transmit packet buffer.
Returns a telecommand transmit packet buffer to the simulator.
bc | A device descriptor. | |
pkt | The telecommand packet buffer. |
References _CO1553_BC_Sim::check, and _CO1553_BC_Sim::cmd_tx_fpa.
Referenced by CTDB_bcPktCmdTxFree().
unsigned int CO1553_bcSimPktCmdTxRecv | ( | CO1553_BC_Sim * | bc, | |
void ** | pkt | |||
) |
Receive a CCSDS telecommand transmit packet.
Waits for a new CCSDS telecommand transmit packet on the bus controller input queue. The function will place a pointer to the new packet in pkt. Call CO1553_bcSimPktCmdTxFree() to return the packet buffer to the simulator.
bc | A simulator descriptor. | |
pkt | Holds the telecommand packet pointer. |
References _CO1553_BC_Sim::check, _CO1553_BC_Sim::cmd_tx_fpa, _CO1553_BC_Sim_Config::cmd_tx_pkt_size, _CO1553_BC_Sim::cmd_tx_sock, CO1553_bcSimSockRead(), CO1553_MSG_SIZE, _CO1553_BC_Sim::hdr_size_cmd, and _CO1553_BC_Sim::sim_config.
Referenced by CTDB_bcPktCmdTxRecv().
unsigned int CO1553_bcSimPktTelemFree | ( | CO1553_BC_Sim * | bc, | |
void * | pkt | |||
) |
Free a CCSDS telemetry packet buffer.
Returns a telemetry packet buffer to the simulator.
bc | A device descriptor. | |
pkt | The telemetry packet buffer. |
References _CO1553_BC_Sim::check, and _CO1553_BC_Sim::telem_fpa.
Referenced by CTDB_bcPktTelemFree().
unsigned int CO1553_bcSimPktTelemRecv | ( | CO1553_BC_Sim * | bc, | |
void ** | pkt | |||
) |
Receive a CCSDS telemetry packet.
Waits for a new CCSDS telemetry packet on the bus controller input queue. The function will place a pointer to the new packet in pkt. Call CO1553_bcSimPktTelemFree() to return the packet buffer to the simulator.
bc | A simulator descriptor. | |
pkt | Holds the telemetry packet pointer. |
References _CO1553_BC_Sim::check, CO1553_bcSimSockRead(), CO1553_MSG_SIZE, _CO1553_BC_Sim::hdr_size_telem, _CO1553_BC_Sim::sim_config, _CO1553_BC_Sim::telem_fpa, _CO1553_BC_Sim_Config::telem_pkt_size, and _CO1553_BC_Sim::telem_sock.
Referenced by CTDB_bcPktTelemRecv().
unsigned int CO1553_bcSimSizeof | ( | void | ) |
Get the size of a bus controller simulator descriptor.
Returns the size of a Summit bus controller simulator descriptor. The user is responsible for allocating this memory before calling SUMT_bcSimInit().
This function is obsolete. Use CO1553_bcSimGet() to provide an instance of the simulator descriptor instead.
Referenced by CTDB_bcSizeof().
static unsigned int CO1553_bcSimSockRead | ( | 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_bcSimPktCmdTxRecv(), and CO1553_bcSimPktTelemRecv().
static unsigned int CO1553_bcSimSockWrite | ( | 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_bcSimPktCmdRxSend().
unsigned int CO1553_bcSimStart | ( | CO1553_BC_Sim * | bc | ) |
Start the bus controller simulator sending 1553 bus commands.
Starts the bus controller sending commands on the bus for the remote terminal. For the simulator, the bus controller TCP client connects to the subaddress sockets.
bc | A simultator descriptor. |
References _CO1553_BC_Sim::check, _CO1553_BC_Sim_Config::cmd_rx_port, _CO1553_BC_Sim::cmd_rx_sock, _CO1553_BC_Sim_Config::cmd_tx_port, _CO1553_BC_Sim::cmd_tx_sock, _CO1553_BC_Sim::rt_addr, _CO1553_BC_Sim::sim_config, _CO1553_BC_Sim_Config::telem_port, and _CO1553_BC_Sim::telem_sock.
Referenced by CTDB_bcStart().
unsigned int CO1553_bcSimStop | ( | CO1553_BC_Sim * | bc | ) |
Stop the bus controller simulator sending 1553 bus commands.
Stops the bus controller sending commands on the bus for the remote terminal. For the simulator, the bus controller TCP client disconnects from the RT server.
bc | A simultator descriptor. |
References _CO1553_BC_Sim::check, _CO1553_BC_Sim::cmd_rx_sock, _CO1553_BC_Sim::cmd_tx_sock, and _CO1553_BC_Sim::telem_sock.
Referenced by CO1553_bcSimExit(), and CTDB_bcStop().
simDesc [static] |
An instance of the simulator descriptor; used for CO1553_bcSimGet().