Commit 3e995526 authored by Federico Vaga's avatar Federico Vaga

wrtd: add software trigger using librt

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>


NOTE
This commit has been created by `git subtree` on the Mock Turtle repository
on tag mock-turtle-2.0

This commit will not compile
parent 2bd59395
......@@ -96,6 +96,10 @@
#define FD_HASH_ENTRIES 64
#define FD_MAX_QUEUE_PULSES 16
enum wrtd_in_actions {
WRTD_IN_ACTION_SW_TRIG = __RT_ACTION_RECV_STANDARD_NUMBER,
};
enum wrtd_in_variables_indexes {
IN_VAR_CHAN_ENABLE = 0,
IN_VAR_DEVICE_TIME_S,
......
......@@ -278,28 +278,34 @@ int wrtd_in_trigger_software(struct wrtd_node *dev,
struct wrtd_trigger_entry *trigger)
{
struct wrtd_desc *wrtd = (struct wrtd_desc *)dev;
struct wrtd_trigger_entry ltrig = *trigger;
struct wrnc_msg msg;
uint32_t *buf = (uint32_t *)trigger;
int err, i;
struct wrnc_proto_header hdr;
int err;
if (trigger == NULL) {
errno = EWRTD_INVALID_TRIG_ID;
return -1;
}
/* Build the message */
msg.datalen = 2 + (sizeof(struct wrtd_trigger_entry) / 4);
msg.data[0] = WRTD_CMD_TDC_SOFTWARE_TRIGGER;
msg.data[1] = 0;
for (i = 2; i < msg.datalen; ++i)
msg.data[i] = buf[i - 2];
memset(&msg, 0, sizeof(struct wrnc_msg));
memset(&hdr, 0, sizeof(struct wrnc_proto_header));
hdr.msg_id = WRTD_IN_ACTION_SW_TRIG;
hdr.slot_io = (WRTD_IN_TDC_CONTROL << 4) | (WRTD_OUT_TDC_CONTROL & 0xF);
hdr.len = sizeof(struct wrtd_trigger_entry) / 4;
hdr.flags = WRNC_PROTO_FLAG_SYNC;
wrtd_timestamp_endianess_fix(&ltrig.ts);
wrnc_message_pack(&msg, &hdr, &ltrig);
/* Send the message and get answer */
err = wrtd_in_send_and_receive_sync(wrtd, &msg);
if (err)
return err;
return wrtd_validate_acknowledge(&msg);
wrnc_message_unpack(&msg, &hdr, NULL);
if (hdr.msg_id != RT_ACTION_SEND_ACK)
return -1;
return 0;
}
......
......@@ -274,6 +274,8 @@ static int wrtd_in_trigger_sw(struct wrnc_proto_header *hin, void *pin,
/* Send trigger */
send_trigger(&ent);
return 0;
}
int wr_enable_lock(int enable)
......@@ -393,14 +395,14 @@ static struct rt_variable wrtd_in_variables[] = {
},
};
#define __WRTD_IN_ACTION_MAX 128 // FIXME
static action_t *wrtd_in_actions[__WRTD_IN_ACTION_MAX] = {
static action_t *wrtd_in_actions[] = {
[RT_ACTION_RECV_PING] = rt_recv_ping,
[RT_ACTION_RECV_VERSION] = rt_version_getter,
[RT_ACTION_RECV_FIELD_SET] = rt_variable_setter,
[RT_ACTION_RECV_FIELD_GET] = rt_variable_getter,
[RT_ACTION_RECV_STRUCT_SET] = rt_structure_setter,
[RT_ACTION_RECV_STRUCT_GET] = rt_structure_getter,
[WRTD_IN_ACTION_SW_TRIG] = wrtd_in_trigger_sw,
};
enum rt_slot_name {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment