static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
- sr_err("scan\n");
struct drv_context *drvc;
GSList *devices;
if(ipdbg_org_la_tcp_open(tcp) != SR_OK)
return NULL;
- sr_err("set Reset\n");
-//////////////////////////////////////////////////////////////////////////////////////////
ipdbg_org_la_sendReset(tcp);
ipdbg_org_la_sendReset(tcp);
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);
- /////////////////////////////////////////////////////////////////////////////////////////////////////////
for (unsigned int i = 0; i < devc->DATA_WIDTH; i++)
{
static int dev_clear(const struct sr_dev_driver *di)
{
- //sr_err("dev_clear\n");
-
struct drv_context *drvc = di->context;
struct sr_dev_inst *sdi;
GSList *l;
static int dev_open(struct sr_dev_inst *sdi)
{
- //sr_err("dev_open\n");
(void)sdi;
- /* TODO: get handle from sdi->conn and open it. */
sdi->status = SR_ST_INACTIVE;
struct ipdbg_org_la_tcp *tcp = sdi->conn;
{
(void)sdi;
- /* TODO: get handle from sdi->conn and close it. */
- //sr_err("dev_close\n");
- /// should be called before a new call to scan()
+ // should be called before a new call to scan()
struct ipdbg_org_la_tcp *tcp = sdi->conn;
if(tcp)
ipdbg_org_la_tcp_close(tcp);
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- //sr_err("config_set\n");
struct ipdbg_org_la_dev_context *devc = sdi->priv;
ret = SR_OK;
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
struct ipdbg_org_la_tcp *tcp = sdi->conn;
struct ipdbg_org_la_dev_context *devc = sdi->priv;
ipdbg_org_la_convert_trigger(sdi);
- //sr_err("dev_acquisition_start\n");
/* Send Triggerkonviguration */
ipdbg_org_la_sendTrigger(devc, tcp);
- //sr_err("dev_acquisition_start1\n");
/* Send Delay */
- ipdbg_org_la_sendDelay(devc, tcp);
- //sr_err("dev_acquisition_start2\n");
+ ipdbg_org_la_sendDelay(devc, tcp);;
- //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,
* 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_err("dev_acquisition_start4\n");
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;
}
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");
-
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
+ unsigned char byte;
+ while (devc->num_transfers < devc->limit_samples_max*devc->DATA_WIDTH_BYTES)
+ {
+ ipdbg_org_la_tcp_receive(tcp, &byte, 1);
+ devc->num_transfers++;
+ }
+ ipdbg_org_la_sendReset(tcp);
ipdbg_org_la_abort_acquisition(sdi);
+
+
return SR_OK;
}
devc->num_stages = 0;
devc->num_transfers = 0;
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_value[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;
}
match = m->data;
unsigned int byteIndex = (match->channel->index) /8;
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)
/* Ignore disabled channels with a trigger. */
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;
{
return FALSE;
}
- //sr_err("receive Data1\n");
if (!(devc = sdi->priv))
{
return FALSE;
}
- //sr_err("receive Data2\n");
struct ipdbg_org_la_tcp *tcp = sdi->conn;
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)
{
- //sr_warn("allocating buffer");
devc->raw_sample_buf = g_try_malloc(devc->limit_samples*devc->DATA_WIDTH_BYTES);
-
if (!devc->raw_sample_buf) {
sr_warn("Sample buffer malloc failed.");
return FALSE;
if (devc->num_transfers < devc->limit_samples_max*devc->DATA_WIDTH_BYTES)
{
- //sr_err("1");
unsigned char byte;
-
if (ipdbg_org_la_tcp_receive(tcp, &byte, 1) == 1)
{
if(devc->num_transfers < devc->limit_samples*devc->DATA_WIDTH_BYTES)
devc->raw_sample_buf[devc->num_transfers] = byte;
+
devc->num_transfers++;
}
}
else
{
- //sr_err("Received %d bytes", devc->num_transfers);
-
- //sr_dbg("Received %d bytes.", devc->num_transfers);
if (devc->delay_value > 0) {
/* There are pre-trigger samples, send those first. */
devc->raw_sample_buf = NULL;
//serial_flush(serial);
- ipdbg_org_la_abort_acquisition(sdi);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ipdbg_org_la_abort_acquisition(sdi);
}
return TRUE;
for(size_t k = 0 ; k < devc->DATA_WIDTH_BYTES ; ++k)
sendEscaping(tcp, devc->trigger_value + devc->DATA_WIDTH_BYTES -1-k, 1);
+
/////////////////////////////////////////////Mask_last////////////////////////////////////////////////////////////
buf[0] = Trigger;
ipdbg_org_la_tcp_send(tcp, buf, 1);
sendEscaping(tcp, devc->trigger_edge_mask + devc->DATA_WIDTH_BYTES -1-k, 1);
+
return SR_OK;
}
while(length--)
{
uint8_t payload = *dataToSend++;
- //sr_warn("payload %d", payload);
-
- //sr_warn("send really");
if ( payload == (uint8_t)reset )
{
{
sr_warn("Can't send data");
}
- //sr_warn("length %d", length);
}
return SR_OK;
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 auslesen[1];
auslesen[0]= K_Mauslesen;
if(ipdbg_org_la_tcp_send(tcp, auslesen, 1) != SR_OK)
sr_warn("Can't send K_Mauslesen");
- //g_usleep(RESPONSE_DELAY_US);
-
/// delay
if(ipdbg_org_la_tcp_receive(tcp, buf, 8) != 8)
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[1] << 8) & 0x0000FF00;
devc->DATA_WIDTH |= (buf[2] << 16) & 0x00FF0000;
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
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->limit_samples_max = (0x01 << devc->ADDR_WIDTH);
- devc->limit_samples = devc->limit_samples_max;// (0x01 << HOST_WORD_SIZE);
- //sr_err("DATA_WIDTH_BYTES: %d ADDR_WIDTH_BYTES : %d LIMIT_SAMPLES: %d", devc->DATA_WIDTH_BYTES, devc->ADDR_WIDTH_BYTES, devc->limit_samples );
+ devc->limit_samples = devc->limit_samples_max;
devc->trigger_value_last = 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
}
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;
sr_session_source_remove(sdi->session, tcp->socket);
- /* Terminate session */
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi);
}
SR_PRIV int ipdbg_org_la_sendStart(struct ipdbg_org_la_tcp *tcp)