ipdbg-la: stop-command
This commit is contained in:
parent
b8fa29a175
commit
b51288e3da
|
@ -335,11 +335,15 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||||
struct ipdbg_org_la_tcp *tcp = sdi->conn;
|
struct ipdbg_org_la_tcp *tcp = sdi->conn;
|
||||||
|
|
||||||
unsigned char byte;
|
unsigned char byte;
|
||||||
|
|
||||||
|
if(devc->num_transfers > 0)
|
||||||
|
{
|
||||||
while (devc->num_transfers < devc->limit_samples_max*devc->DATA_WIDTH_BYTES)
|
while (devc->num_transfers < devc->limit_samples_max*devc->DATA_WIDTH_BYTES)
|
||||||
{
|
{
|
||||||
ipdbg_org_la_tcp_receive(tcp, &byte, 1);
|
ipdbg_org_la_tcp_receive(tcp, &byte);
|
||||||
devc->num_transfers++;
|
devc->num_transfers++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ipdbg_org_la_sendReset(tcp);
|
ipdbg_org_la_sendReset(tcp);
|
||||||
ipdbg_org_la_abort_acquisition(sdi);
|
ipdbg_org_la_abort_acquisition(sdi);
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
#define BUFFER_SIZE 4
|
#define BUFFER_SIZE 4
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,6 +68,36 @@
|
||||||
#define delay 0x1F
|
#define delay 0x1F
|
||||||
#define K_Mauslesen 0xAA
|
#define K_Mauslesen 0xAA
|
||||||
|
|
||||||
|
int hasData(struct ipdbg_org_la_tcp *tcp)
|
||||||
|
{
|
||||||
|
#ifdef __WIN32__
|
||||||
|
ioctlsocket(tcp->socket,FIONREAD,&bytes_available);
|
||||||
|
#else
|
||||||
|
//ioctl(fd,FIONREAD,&bytes_available);
|
||||||
|
int status;
|
||||||
|
|
||||||
|
//fd = open("/dev/ttyS0", O_RDONLY);
|
||||||
|
if (ioctl(tcp->socket, FIONREAD, &status) < 0) //TIOCMGET
|
||||||
|
{
|
||||||
|
sr_err("FIONREAD failed: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (status < 1)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __WIN32__
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SR_PRIV int sendEscaping(struct ipdbg_org_la_tcp *tcp, char *dataToSend, int length);
|
SR_PRIV int sendEscaping(struct ipdbg_org_la_tcp *tcp, char *dataToSend, int length);
|
||||||
|
|
||||||
|
@ -141,17 +173,32 @@ SR_PRIV int ipdbg_org_la_tcp_send(struct ipdbg_org_la_tcp *tcp, const uint8_t *b
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV int ipdbg_org_la_tcp_receive(struct ipdbg_org_la_tcp *tcp, uint8_t *buf, int bufsize)
|
SR_PRIV int ipdbg_org_la_tcp_receive_blocking(struct ipdbg_org_la_tcp *tcp, uint8_t *buf, int bufsize)
|
||||||
|
{
|
||||||
|
int received = 0;
|
||||||
|
while (received < bufsize)
|
||||||
|
{
|
||||||
|
int valid = ipdbg_org_la_tcp_receive(tcp, buf);
|
||||||
|
if(valid >0)
|
||||||
|
{
|
||||||
|
++buf;
|
||||||
|
++received;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return received;
|
||||||
|
}
|
||||||
|
SR_PRIV int ipdbg_org_la_tcp_receive(struct ipdbg_org_la_tcp *tcp, uint8_t *buf)
|
||||||
{
|
{
|
||||||
int received = 0;
|
int received = 0;
|
||||||
|
|
||||||
while(received < bufsize)
|
if (hasData(tcp) == 1)
|
||||||
{
|
{
|
||||||
int len;
|
while(received < 1)
|
||||||
|
{
|
||||||
|
int len = recv(tcp->socket, buf, 1, 0);
|
||||||
|
|
||||||
len = recv(tcp->socket, (char*)(buf+received), bufsize-received, 0);
|
if (len < 0)
|
||||||
|
{
|
||||||
if (len < 0) {
|
|
||||||
sr_err("Receive error: %s", g_strerror(errno));
|
sr_err("Receive error: %s", g_strerror(errno));
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
|
@ -160,10 +207,15 @@ SR_PRIV int ipdbg_org_la_tcp_receive(struct ipdbg_org_la_tcp *tcp, uint8_t *buf,
|
||||||
received += len;
|
received += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return received;
|
return received;
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
SR_PRIV int ipdbg_org_la_tcp_close(struct ipdbg_org_la_tcp *tcp)
|
SR_PRIV int ipdbg_org_la_tcp_close(struct ipdbg_org_la_tcp *tcp)
|
||||||
{
|
{
|
||||||
int ret = SR_ERR;
|
int ret = SR_ERR;
|
||||||
|
@ -315,7 +367,7 @@ SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data)
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -503,11 +555,10 @@ SR_PRIV void ipdbg_org_la_get_addrwidth_and_datawidth(struct ipdbg_org_la_tcp *t
|
||||||
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");
|
||||||
|
|
||||||
|
if (ipdbg_org_la_tcp_receive_blocking(tcp, buf,8)!=8)
|
||||||
/// delay
|
|
||||||
if(ipdbg_org_la_tcp_receive(tcp, buf, 8) != 8)
|
|
||||||
sr_warn("getAddrAndDataWidth failed");
|
sr_warn("getAddrAndDataWidth failed");
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
@ -567,7 +618,7 @@ SR_PRIV int ipdbg_org_la_requestID(struct ipdbg_org_la_tcp *tcp)
|
||||||
sr_warn("IDBG can't send");
|
sr_warn("IDBG can't send");
|
||||||
|
|
||||||
char ID[4];
|
char ID[4];
|
||||||
if(ipdbg_org_la_tcp_receive(tcp, (uint8_t*)ID, 4) != 4)
|
if(ipdbg_org_la_tcp_receive_blocking(tcp, (uint8_t*)ID, 4) != 4)
|
||||||
{
|
{
|
||||||
sr_warn("IDBG can't read");
|
sr_warn("IDBG can't read");
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ SR_PRIV int ipdbg_org_la_tcp_open(struct ipdbg_org_la_tcp *tcp);
|
||||||
SR_PRIV int ipdbg_org_la_tcp_close(struct ipdbg_org_la_tcp *tcp);
|
SR_PRIV int ipdbg_org_la_tcp_close(struct ipdbg_org_la_tcp *tcp);
|
||||||
SR_PRIV void ipdbg_org_la_tcp_free(struct ipdbg_org_la_tcp *tcp);
|
SR_PRIV void ipdbg_org_la_tcp_free(struct ipdbg_org_la_tcp *tcp);
|
||||||
SR_PRIV int ipdbg_org_la_tcp_send(struct ipdbg_org_la_tcp *tcp, const uint8_t *buf, size_t len);
|
SR_PRIV int ipdbg_org_la_tcp_send(struct ipdbg_org_la_tcp *tcp, const uint8_t *buf, size_t len);
|
||||||
SR_PRIV int ipdbg_org_la_tcp_receive(struct ipdbg_org_la_tcp *tcp, uint8_t *buf, int bufsize);
|
SR_PRIV int ipdbg_org_la_tcp_receive(struct ipdbg_org_la_tcp *tcp, uint8_t *buf);
|
||||||
|
|
||||||
SR_PRIV struct ipdbg_org_la_dev_context *ipdbg_org_la_dev_new(void);
|
SR_PRIV struct ipdbg_org_la_dev_context *ipdbg_org_la_dev_new(void);
|
||||||
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);
|
||||||
|
@ -73,5 +73,7 @@ SR_PRIV int ipdbg_org_la_sendDelay(struct ipdbg_org_la_dev_context *devc, struct
|
||||||
SR_PRIV int ipdbg_org_la_convert_trigger(const struct sr_dev_inst *sdi);
|
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_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);
|
||||||
|
SR_PRIV int ipdbg_org_la_tcp_receive_blocking(struct ipdbg_org_la_tcp *tcp, uint8_t *buf, int bufsize);
|
||||||
|
int hasData(struct ipdbg_org_la_tcp *tcp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue