ipdbg-la: stop-function pulseview

This commit is contained in:
Eva Kissling 2017-09-28 13:32:32 +02:00 committed by Uwe Hermann
parent a66099c6fa
commit b8fa29a175
3 changed files with 22 additions and 76 deletions

View File

@ -59,7 +59,6 @@ static void ipdbg_org_la_split_addr_port(const char *conn, char **addr, char **p
static GSList *scan(struct sr_dev_driver *di, GSList *options) static GSList *scan(struct sr_dev_driver *di, GSList *options)
{ {
sr_err("scan\n");
struct drv_context *drvc; struct drv_context *drvc;
GSList *devices; GSList *devices;
@ -96,8 +95,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
if(ipdbg_org_la_tcp_open(tcp) != SR_OK) if(ipdbg_org_la_tcp_open(tcp) != SR_OK)
return NULL; return NULL;
sr_err("set Reset\n");
//////////////////////////////////////////////////////////////////////////////////////////
ipdbg_org_la_sendReset(tcp); ipdbg_org_la_sendReset(tcp);
ipdbg_org_la_sendReset(tcp); ipdbg_org_la_sendReset(tcp);
@ -124,7 +121,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
sr_err("addr_width = %d, data_width = %d\n", devc->ADDR_WIDTH, devc->DATA_WIDTH); sr_err("addr_width = %d, data_width = %d\n", devc->ADDR_WIDTH, devc->DATA_WIDTH);
sr_err("limit samples = %d\n", devc->limit_samples_max); sr_err("limit samples = %d\n", devc->limit_samples_max);
/////////////////////////////////////////////////////////////////////////////////////////////////////////
for (unsigned int i = 0; i < devc->DATA_WIDTH; i++) for (unsigned int i = 0; i < devc->DATA_WIDTH; i++)
{ {
@ -145,8 +141,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
static int dev_clear(const struct sr_dev_driver *di) static int dev_clear(const struct sr_dev_driver *di)
{ {
//sr_err("dev_clear\n");
struct drv_context *drvc = di->context; struct drv_context *drvc = di->context;
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
GSList *l; GSList *l;
@ -170,10 +164,8 @@ static int dev_clear(const struct sr_dev_driver *di)
static int dev_open(struct sr_dev_inst *sdi) static int dev_open(struct sr_dev_inst *sdi)
{ {
//sr_err("dev_open\n");
(void)sdi; (void)sdi;
/* TODO: get handle from sdi->conn and open it. */
sdi->status = SR_ST_INACTIVE; sdi->status = SR_ST_INACTIVE;
struct ipdbg_org_la_tcp *tcp = sdi->conn; struct ipdbg_org_la_tcp *tcp = sdi->conn;
@ -195,9 +187,7 @@ static int dev_close(struct sr_dev_inst *sdi)
{ {
(void)sdi; (void)sdi;
/* TODO: get handle from sdi->conn and close it. */ // should be called before a new call to scan()
//sr_err("dev_close\n");
/// should be called before a new call to scan()
struct ipdbg_org_la_tcp *tcp = sdi->conn; struct ipdbg_org_la_tcp *tcp = sdi->conn;
if(tcp) if(tcp)
ipdbg_org_la_tcp_close(tcp); ipdbg_org_la_tcp_close(tcp);
@ -246,7 +236,6 @@ static int config_set(uint32_t key, GVariant *data,
if (sdi->status != SR_ST_ACTIVE) if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED; return SR_ERR_DEV_CLOSED;
//sr_err("config_set\n");
struct ipdbg_org_la_dev_context *devc = sdi->priv; struct ipdbg_org_la_dev_context *devc = sdi->priv;
ret = SR_OK; ret = SR_OK;
@ -316,7 +305,6 @@ static GSList *dev_list(const struct sr_dev_driver *di)
static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{ {
if (sdi->status != SR_ST_ACTIVE) if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED; return SR_ERR_DEV_CLOSED;
struct ipdbg_org_la_tcp *tcp = sdi->conn; struct ipdbg_org_la_tcp *tcp = sdi->conn;
@ -324,45 +312,40 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct ipdbg_org_la_dev_context *devc = sdi->priv; struct ipdbg_org_la_dev_context *devc = sdi->priv;
ipdbg_org_la_convert_trigger(sdi); ipdbg_org_la_convert_trigger(sdi);
//sr_err("dev_acquisition_start\n");
/* Send Triggerkonviguration */ /* Send Triggerkonviguration */
ipdbg_org_la_sendTrigger(devc, tcp); ipdbg_org_la_sendTrigger(devc, tcp);
//sr_err("dev_acquisition_start1\n");
/* Send Delay */ /* Send Delay */
ipdbg_org_la_sendDelay(devc, tcp); ipdbg_org_la_sendDelay(devc, tcp);;
//sr_err("dev_acquisition_start2\n");
//std_session_send_df_header(sdi, LOG_PREFIX);
std_session_send_df_header(sdi);
//sr_err("dev_acquisition_start3\n");
/* If the device stops sending for longer than it takes to send a byte, /* If the device stops sending for longer than it takes to send a byte,
* that means it's finished. But wait at least 100 ms to be safe. * that means it's finished. But wait at least 100 ms to be safe.
*/ */
//sr_session_source_add(sdi->session, -1, G_IO_IN, 100, ipdbg_receive_data, (struct sr_dev_inst *)sdi);
//sr_session_source_add(sdi->session, -1, G_IO_IN, 100, ipdbg_org_la_receive_data, NULL);
sr_session_source_add(sdi->session, tcp->socket, G_IO_IN, 100, ipdbg_org_la_receive_data, (struct sr_dev_inst *)sdi); sr_session_source_add(sdi->session, tcp->socket, G_IO_IN, 100, ipdbg_org_la_receive_data, (struct sr_dev_inst *)sdi);
//sr_err("dev_acquisition_start4\n");
ipdbg_org_la_sendStart(tcp); ipdbg_org_la_sendStart(tcp);
//sr_err("dev_acquisition_start5\n");
/* TODO: configure hardware, reset acquisition state, set up
* callbacks and send header packet. */
return SR_OK; return SR_OK;
} }
static int dev_acquisition_stop(struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{ {
struct ipdbg_org_la_dev_context *devc = sdi->priv;
struct ipdbg_org_la_tcp *tcp = sdi->conn;
sr_err("dev_acquisition_stop\n"); unsigned char byte;
while (devc->num_transfers < devc->limit_samples_max*devc->DATA_WIDTH_BYTES)
if (sdi->status != SR_ST_ACTIVE) {
return SR_ERR_DEV_CLOSED; ipdbg_org_la_tcp_receive(tcp, &byte, 1);
devc->num_transfers++;
}
ipdbg_org_la_sendReset(tcp);
ipdbg_org_la_abort_acquisition(sdi); ipdbg_org_la_abort_acquisition(sdi);
return SR_OK; return SR_OK;
} }

View File

@ -194,7 +194,7 @@ SR_PRIV int ipdbg_org_la_convert_trigger(const struct sr_dev_inst *sdi)
devc->num_stages = 0; devc->num_stages = 0;
devc->num_transfers = 0; devc->num_transfers = 0;
devc->raw_sample_buf = NULL; /// name convert_trigger to init acquisition... devc->raw_sample_buf = NULL; /// name convert_trigger to init acquisition...
for (unsigned int i = 0; i < devc->DATA_WIDTH_BYTES; i++) // Hier werden die Trigger-Variabeln 0 gesetzt! for (unsigned int i = 0; i < devc->DATA_WIDTH_BYTES; i++)
{ {
devc->trigger_mask[i] = 0; devc->trigger_mask[i] = 0;
devc->trigger_value[i] = 0; devc->trigger_value[i] = 0;
@ -203,7 +203,7 @@ SR_PRIV int ipdbg_org_la_convert_trigger(const struct sr_dev_inst *sdi)
devc->trigger_edge_mask[i] = 0; devc->trigger_edge_mask[i] = 0;
} }
if (!(trigger = sr_session_trigger_get(sdi->session))) // if (!(trigger = sr_session_trigger_get(sdi->session)))
{ {
return SR_OK; return SR_OK;
} }
@ -216,10 +216,6 @@ SR_PRIV int ipdbg_org_la_convert_trigger(const struct sr_dev_inst *sdi)
match = m->data; match = m->data;
unsigned int byteIndex = (match->channel->index) /8; unsigned int byteIndex = (match->channel->index) /8;
unsigned char matchPattern = 1 << (match->channel->index - 8* byteIndex); unsigned char matchPattern = 1 << (match->channel->index - 8* byteIndex);
//zeroTrigger |= matchPattern;
//sr_err("\n\nzerotrigger:%x\n\n",zeroTrigger);
//sr_err("\nbyteIndex:%i",byteIndex);
//sr_err("\nmatch Pattern:%i\n",matchPattern);
if (!match->channel->enabled) if (!match->channel->enabled)
/* Ignore disabled channels with a trigger. */ /* Ignore disabled channels with a trigger. */
@ -276,7 +272,6 @@ SR_PRIV int ipdbg_org_la_convert_trigger(const struct sr_dev_inst *sdi)
SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data) SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data)
{ {
//sr_err("receive Data0\n");
const struct sr_dev_inst *sdi; const struct sr_dev_inst *sdi;
@ -292,14 +287,12 @@ SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data)
{ {
return FALSE; return FALSE;
} }
//sr_err("receive Data1\n");
if (!(devc = sdi->priv)) if (!(devc = sdi->priv))
{ {
return FALSE; return FALSE;
} }
//sr_err("receive Data2\n");
struct ipdbg_org_la_tcp *tcp = sdi->conn; struct ipdbg_org_la_tcp *tcp = sdi->conn;
@ -307,20 +300,9 @@ SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data)
struct sr_datafeed_logic logic; struct sr_datafeed_logic logic;
/*sr_warn("---");
if (devc->num_transfers == 0 && revents == 0)
{ //
sr_warn("warten auf Eingangsdaten");
// Ignore timeouts as long as we haven't received anything
return TRUE;
}*/
if (!devc->raw_sample_buf) if (!devc->raw_sample_buf)
{ {
//sr_warn("allocating buffer");
devc->raw_sample_buf = g_try_malloc(devc->limit_samples*devc->DATA_WIDTH_BYTES); devc->raw_sample_buf = g_try_malloc(devc->limit_samples*devc->DATA_WIDTH_BYTES);
if (!devc->raw_sample_buf) { if (!devc->raw_sample_buf) {
sr_warn("Sample buffer malloc failed."); sr_warn("Sample buffer malloc failed.");
return FALSE; return FALSE;
@ -331,23 +313,19 @@ SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data)
if (devc->num_transfers < devc->limit_samples_max*devc->DATA_WIDTH_BYTES) if (devc->num_transfers < devc->limit_samples_max*devc->DATA_WIDTH_BYTES)
{ {
//sr_err("1");
unsigned char byte; unsigned char byte;
if (ipdbg_org_la_tcp_receive(tcp, &byte, 1) == 1) if (ipdbg_org_la_tcp_receive(tcp, &byte, 1) == 1)
{ {
if(devc->num_transfers < devc->limit_samples*devc->DATA_WIDTH_BYTES) if(devc->num_transfers < devc->limit_samples*devc->DATA_WIDTH_BYTES)
devc->raw_sample_buf[devc->num_transfers] = byte; devc->raw_sample_buf[devc->num_transfers] = byte;
devc->num_transfers++; devc->num_transfers++;
} }
} }
else else
{ {
//sr_err("Received %d bytes", devc->num_transfers);
//sr_dbg("Received %d bytes.", devc->num_transfers);
if (devc->delay_value > 0) { if (devc->delay_value > 0) {
/* There are pre-trigger samples, send those first. */ /* There are pre-trigger samples, send those first. */
@ -378,7 +356,7 @@ SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data)
devc->raw_sample_buf = NULL; devc->raw_sample_buf = NULL;
//serial_flush(serial); //serial_flush(serial);
ipdbg_org_la_abort_acquisition(sdi);////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ipdbg_org_la_abort_acquisition(sdi);
} }
return TRUE; return TRUE;
@ -439,6 +417,7 @@ SR_PRIV int ipdbg_org_la_sendTrigger(struct ipdbg_org_la_dev_context *devc, stru
for(size_t k = 0 ; k < devc->DATA_WIDTH_BYTES ; ++k) for(size_t k = 0 ; k < devc->DATA_WIDTH_BYTES ; ++k)
sendEscaping(tcp, devc->trigger_value + devc->DATA_WIDTH_BYTES -1-k, 1); sendEscaping(tcp, devc->trigger_value + devc->DATA_WIDTH_BYTES -1-k, 1);
/////////////////////////////////////////////Mask_last//////////////////////////////////////////////////////////// /////////////////////////////////////////////Mask_last////////////////////////////////////////////////////////////
buf[0] = Trigger; buf[0] = Trigger;
ipdbg_org_la_tcp_send(tcp, buf, 1); ipdbg_org_la_tcp_send(tcp, buf, 1);
@ -476,6 +455,7 @@ SR_PRIV int ipdbg_org_la_sendTrigger(struct ipdbg_org_la_dev_context *devc, stru
sendEscaping(tcp, devc->trigger_edge_mask + devc->DATA_WIDTH_BYTES -1-k, 1); sendEscaping(tcp, devc->trigger_edge_mask + devc->DATA_WIDTH_BYTES -1-k, 1);
return SR_OK; return SR_OK;
} }
@ -484,9 +464,6 @@ SR_PRIV int sendEscaping(struct ipdbg_org_la_tcp *tcp, char *dataToSend, int len
while(length--) while(length--)
{ {
uint8_t payload = *dataToSend++; uint8_t payload = *dataToSend++;
//sr_warn("payload %d", payload);
//sr_warn("send really");
if ( payload == (uint8_t)reset ) if ( payload == (uint8_t)reset )
{ {
@ -512,7 +489,6 @@ SR_PRIV int sendEscaping(struct ipdbg_org_la_tcp *tcp, char *dataToSend, int len
{ {
sr_warn("Can't send data"); sr_warn("Can't send data");
} }
//sr_warn("length %d", length);
} }
return SR_OK; return SR_OK;
@ -520,23 +496,18 @@ SR_PRIV int sendEscaping(struct ipdbg_org_la_tcp *tcp, char *dataToSend, int len
SR_PRIV void ipdbg_org_la_get_addrwidth_and_datawidth(struct ipdbg_org_la_tcp *tcp, struct ipdbg_org_la_dev_context *devc) SR_PRIV void ipdbg_org_la_get_addrwidth_and_datawidth(struct ipdbg_org_la_tcp *tcp, struct ipdbg_org_la_dev_context *devc)
{ {
//sr_err("getAddrAndDataWidth\n");
uint8_t buf[8]; uint8_t buf[8];
uint8_t auslesen[1]; uint8_t auslesen[1];
auslesen[0]= K_Mauslesen; auslesen[0]= K_Mauslesen;
if(ipdbg_org_la_tcp_send(tcp, auslesen, 1) != SR_OK) if(ipdbg_org_la_tcp_send(tcp, auslesen, 1) != SR_OK)
sr_warn("Can't send K_Mauslesen"); sr_warn("Can't send K_Mauslesen");
//g_usleep(RESPONSE_DELAY_US);
/// delay /// delay
if(ipdbg_org_la_tcp_receive(tcp, buf, 8) != 8) if(ipdbg_org_la_tcp_receive(tcp, buf, 8) != 8)
sr_warn("getAddrAndDataWidth failed"); sr_warn("getAddrAndDataWidth failed");
//sr_warn("getAddrAndDataWidth 0x%x:0x%x:0x%x:0x%x 0x%x:0x%x:0x%x:0x%x", buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7]);
devc->DATA_WIDTH = buf[0] & 0x000000FF; devc->DATA_WIDTH = buf[0] & 0x000000FF;
devc->DATA_WIDTH |= (buf[1] << 8) & 0x0000FF00; devc->DATA_WIDTH |= (buf[1] << 8) & 0x0000FF00;
devc->DATA_WIDTH |= (buf[2] << 16) & 0x00FF0000; devc->DATA_WIDTH |= (buf[2] << 16) & 0x00FF0000;
@ -548,16 +519,12 @@ SR_PRIV void ipdbg_org_la_get_addrwidth_and_datawidth(struct ipdbg_org_la_tcp *t
devc->ADDR_WIDTH |= (buf[7] << 24) & 0xFF000000; devc->ADDR_WIDTH |= (buf[7] << 24) & 0xFF000000;
//sr_warn("Datawidth: %d Addrwdth : %d", devc->DATA_WIDTH, devc->ADDR_WIDTH);
int HOST_WORD_SIZE = 8; // bits/ word int HOST_WORD_SIZE = 8; // bits/ word
devc->DATA_WIDTH_BYTES = (devc->DATA_WIDTH+HOST_WORD_SIZE -1)/HOST_WORD_SIZE; devc->DATA_WIDTH_BYTES = (devc->DATA_WIDTH+HOST_WORD_SIZE -1)/HOST_WORD_SIZE;
devc->ADDR_WIDTH_BYTES = (devc->ADDR_WIDTH+HOST_WORD_SIZE -1)/HOST_WORD_SIZE; devc->ADDR_WIDTH_BYTES = (devc->ADDR_WIDTH+HOST_WORD_SIZE -1)/HOST_WORD_SIZE;
devc->limit_samples_max = (0x01 << devc->ADDR_WIDTH); devc->limit_samples_max = (0x01 << devc->ADDR_WIDTH);
devc->limit_samples = devc->limit_samples_max;// (0x01 << HOST_WORD_SIZE); devc->limit_samples = devc->limit_samples_max;
//sr_err("DATA_WIDTH_BYTES: %d ADDR_WIDTH_BYTES : %d LIMIT_SAMPLES: %d", devc->DATA_WIDTH_BYTES, devc->ADDR_WIDTH_BYTES, devc->limit_samples );
@ -567,7 +534,6 @@ SR_PRIV void ipdbg_org_la_get_addrwidth_and_datawidth(struct ipdbg_org_la_tcp *t
devc->trigger_value_last = g_malloc0(devc->DATA_WIDTH_BYTES); devc->trigger_value_last = g_malloc0(devc->DATA_WIDTH_BYTES);
devc->trigger_edge_mask = g_malloc0(devc->DATA_WIDTH_BYTES); devc->trigger_edge_mask = g_malloc0(devc->DATA_WIDTH_BYTES);
// TODO add missing free for trigger_mask, trigger_value, trigger_mask_last, trigger_value_last and trigger_edge_mask
} }
@ -617,15 +583,12 @@ SR_PRIV int ipdbg_org_la_requestID(struct ipdbg_org_la_tcp *tcp)
SR_PRIV void ipdbg_org_la_abort_acquisition(const struct sr_dev_inst *sdi) SR_PRIV void ipdbg_org_la_abort_acquisition(const struct sr_dev_inst *sdi)
{ {
struct sr_datafeed_packet packet;
struct ipdbg_org_la_tcp *tcp = sdi->conn; struct ipdbg_org_la_tcp *tcp = sdi->conn;
sr_session_source_remove(sdi->session, tcp->socket); sr_session_source_remove(sdi->session, tcp->socket);
/* Terminate session */ std_session_send_df_end(sdi);
packet.type = SR_DF_END;
sr_session_send(sdi, &packet);
} }
SR_PRIV int ipdbg_org_la_sendStart(struct ipdbg_org_la_tcp *tcp) SR_PRIV int ipdbg_org_la_sendStart(struct ipdbg_org_la_tcp *tcp)

View File

@ -51,7 +51,7 @@ struct ipdbg_org_la_dev_context
char *trigger_value_last; char *trigger_value_last;
char *trigger_edge_mask; char *trigger_edge_mask;
unsigned int delay_value; unsigned int delay_value;
int num_stages; //always 0 int num_stages;
unsigned int num_transfers; unsigned int num_transfers;
unsigned char *raw_sample_buf; unsigned char *raw_sample_buf;
}; };