parts of p60dock handler
This commit is contained in:
@ -20,7 +20,7 @@ SystemObject(objectId_){
|
||||
|
||||
ReturnValue_t P60DockTestTask::performOperation(uint8_t operationCode) {
|
||||
|
||||
if(sendPacket() != HasReturnvaluesIF::RETURN_OK){
|
||||
if(pingP60dock() != HasReturnvaluesIF::RETURN_OK){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -31,43 +31,7 @@ ReturnValue_t P60DockTestTask::performOperation(uint8_t operationCode) {
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t P60DockTestTask::sendPacket(void){
|
||||
|
||||
// char *msg = "HELLO";
|
||||
// /* Get packet buffer for data */
|
||||
// csp_packet_t *packet = csp_buffer_get(strlen(msg));
|
||||
// if (packet == NULL) {
|
||||
// /* Could not get buffer element */
|
||||
// sif::error("Failed to get buffer element\\n");
|
||||
// return HasReturnvaluesIF::RETURN_FAILED;
|
||||
// }
|
||||
//
|
||||
// /* Connect P60 Dock */
|
||||
// csp_conn_t *conn = csp_connect(CSP_PRIO_NORM, c, CSP_PING,
|
||||
// 1000, CSP_O_NONE);
|
||||
//
|
||||
// if (conn == NULL) {
|
||||
// /* Connect failed */
|
||||
// sif::error("Connection failed\\n");
|
||||
// /* Remember to free packet buffer */
|
||||
// csp_buffer_free(packet);
|
||||
// return HasReturnvaluesIF::RETURN_FAILED;
|
||||
// }
|
||||
//
|
||||
// /* Copy message to packet */
|
||||
// strcpy(packet->data, msg);
|
||||
// /* Set packet length */
|
||||
// packet->length = strlen(msg);
|
||||
//
|
||||
// /* Send packet */
|
||||
// if (!csp_send(conn, packet, 1000)) {
|
||||
// /* Send failed */
|
||||
// sif::error("Send failed\\n");
|
||||
// csp_buffer_free(packet);
|
||||
// }
|
||||
// /* Close connection */
|
||||
// csp_close(conn);
|
||||
|
||||
ReturnValue_t P60DockTestTask::pingP60dock(void){
|
||||
uint32_t timeout = 1000;
|
||||
unsigned int pingSize = 100; // 100 bytes
|
||||
uint32_t replyTime = csp_ping(p60dockAddress, timeout, pingSize, CSP_O_NONE);
|
||||
@ -78,54 +42,35 @@ ReturnValue_t P60DockTestTask::sendPacket(void){
|
||||
|
||||
|
||||
ReturnValue_t P60DockTestTask::getParameters(void) {
|
||||
// int result = rparam_get_full_table(&node_hk, p60dock_node, P60_PORT_RPARAM,
|
||||
uint32_t timeout = 1000;
|
||||
node_hk.rows = (gs_param_table_row_t*)p60dock_hk;
|
||||
node_hk.id = P60DOCK_HK;
|
||||
node_hk.row_count = p60dock_hk_count;
|
||||
node_hk.memory_size = P60DOCK_HK_SIZE;
|
||||
node_hk.memory = hk_mem;
|
||||
node_hk.memory = hkMem;
|
||||
/* Retriev all houskeeping data from the P60 dock and store it in hkMem
|
||||
* array */
|
||||
int result = gs_rparam_get_full_table(&node_hk, p60dockAddress, node_hk.id,
|
||||
GS_RPARAM_MAGIC_CHECKSUM, timeout);
|
||||
|
||||
if (result != 0) {
|
||||
sif::info << "Error retrieving P60 Dock housekeeping\n" << std::endl;
|
||||
sif::info << "Error retrieving P60 Dock housekeeping" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
} else {
|
||||
uint8_t tableOffsetTemperature = 0x44;
|
||||
int16_t temperature[2];
|
||||
int16_t temperature;
|
||||
size_t parameterSize = sizeof(temperature);
|
||||
uint32_t flags = 0;
|
||||
result = gs_param_get_data((gs_param_table_instance_t*) &node_hk,
|
||||
tableOffsetTemperature, temperature, parameterSize, flags);
|
||||
sif::info << "P60 Dock Temperature 1: " << temperature[0] << std::endl;
|
||||
sif::info << "P60 Dock Temperature 2: " << temperature[1] << std::endl;
|
||||
tableOffsetTemperature, &temperature, parameterSize, flags);
|
||||
sif::info << "P60 Dock Temperature: " << temperature << std::endl;
|
||||
|
||||
// sif::info << "Retrieved P60 Dock housekeeping\n" << std::endl;
|
||||
// /* List all out_en[] values, using parameter name */
|
||||
// const param_table_t * param = param_find_name(node_hk.table,
|
||||
// node_hk.count, "out_en");
|
||||
// if (param != NULL) {
|
||||
// for (uint8_t index = 0; index < 13; index++) {
|
||||
// /* Read parameter using name */
|
||||
// uint8_t *out_en = param_read_addr(
|
||||
// param->addr + param->size * index, &node_hk,
|
||||
// param->size);
|
||||
// sif::info << "out_en" << index << ": " << *out_en << std::endl;
|
||||
// }
|
||||
// }
|
||||
// /* List all c_out[] values, using parameter address */
|
||||
// param = param_find_addr(node_hk.table, node_hk.count, 0x0000);
|
||||
// if (param != NULL) {
|
||||
// for (uint8_t index = 0; index < 13; index++) {
|
||||
// /* Read parameter using address */
|
||||
// int16_t *c_out = param_read_addr(
|
||||
// param->addr + param->size * index, &node_hk,
|
||||
// param->size);
|
||||
// sif::info << "c_out" << index << ": " << *c_out << "mA"
|
||||
// << std::endl;
|
||||
// }
|
||||
// }
|
||||
uint16_t vbat_v;
|
||||
parameterSize = sizeof(vbat_v);
|
||||
uint8_t vbat_v_offset = 0x74;
|
||||
result = gs_param_get_data((gs_param_table_instance_t*) &node_hk,
|
||||
vbat_v_offset, &vbat_v, parameterSize, flags);
|
||||
sif::info << "VBAT_V: " << vbat_v << std::endl;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
@ -133,7 +78,7 @@ ReturnValue_t P60DockTestTask::getParameters(void) {
|
||||
|
||||
ReturnValue_t P60DockTestTask::initializeCSPStack(void){
|
||||
/* Init CSP and CSP buffer system */
|
||||
if (csp_init(cspAddress) != CSP_ERR_NONE
|
||||
if (csp_init(cspClientAddress) != CSP_ERR_NONE
|
||||
|| csp_buffer_init(10, 300) != CSP_ERR_NONE) {
|
||||
sif::error << "Failed to init CSP\r\n" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
|
@ -30,21 +30,26 @@ public:
|
||||
private:
|
||||
/* Interface struct for csp protocol stack */
|
||||
csp_iface_t csp_if;
|
||||
/* CSP address of P60 dock */
|
||||
uint8_t p60dockAddress = 4;
|
||||
uint8_t CSP_PING = 1;
|
||||
uint8_t cspAddress = 1;
|
||||
/* Client CSP address */
|
||||
uint8_t cspClientAddress = 1;
|
||||
/* CAN interface used by CSP */
|
||||
const char* canIf = "can0";
|
||||
int bitrate = 1000; // bitrate of can
|
||||
int promisc = 0; // set to 0 to enable filter mode
|
||||
|
||||
uint8_t hk_mem[P60DOCK_HK_SIZE];
|
||||
uint8_t p60dock_node = 4;
|
||||
/* P60 Dock houskeeping parameters will be stored in this buffer */
|
||||
uint8_t hkMem[P60DOCK_HK_SIZE];
|
||||
gs_param_table_instance_t node_hk;
|
||||
/* Port of CSP ping requests on P60 dock */
|
||||
uint8_t CSP_PING = 1;
|
||||
|
||||
ReturnValue_t sendPacket(void);
|
||||
/* Sends ping request and receives ping reply */
|
||||
ReturnValue_t pingP60dock(void);
|
||||
ReturnValue_t initializeCSPStack(void);
|
||||
/* Temperature and raw battery voltage are read from the P60 dock by this
|
||||
* function */
|
||||
ReturnValue_t getParameters(void);
|
||||
|
||||
};
|
||||
|
||||
#endif /* TEST_TESTTASKS_P60DOCKTESTTASK_H_ */
|
||||
|
Reference in New Issue
Block a user