Work in progress.

merge-requests/1/head
Teuniz 2015-06-27 19:37:06 +02:00
rodzic 58e697a826
commit 0a40bc26d8
2 zmienionych plików z 27 dodań i 3 usunięć

Wyświetl plik

@ -31,7 +31,7 @@
#define PROGRAM_NAME "DSRemote" #define PROGRAM_NAME "DSRemote"
#define PROGRAM_VERSION "0.20_1506271641" #define PROGRAM_VERSION "0.20_1506271933"
#define MAX_PATHLEN 4096 #define MAX_PATHLEN 4096

Wyświetl plik

@ -96,9 +96,10 @@ void tmcdev_close(struct tmcdev *dev)
int tmcdev_write(struct tmcdev *dev, const char *cmd) int tmcdev_write(struct tmcdev *dev, const char *cmd)
{ {
int size; int i, size, qry;
char buf[MAX_CMD_LEN + 16]; char buf[MAX_CMD_LEN + 16],
str[256];
if(dev == NULL) if(dev == NULL)
{ {
@ -119,6 +120,11 @@ int tmcdev_write(struct tmcdev *dev, const char *cmd)
return -1; return -1;
} }
if(cmd[strlen(cmd) - 1] == '?')
{
qry = 1;
}
strncpy(buf, cmd, MAX_CMD_LEN); strncpy(buf, cmd, MAX_CMD_LEN);
buf[MAX_CMD_LEN] = 0; buf[MAX_CMD_LEN] = 0;
@ -146,6 +152,24 @@ int tmcdev_write(struct tmcdev *dev, const char *cmd)
printf("tmcdev error: device write error"); printf("tmcdev error: device write error");
} }
if(!qry)
{
for(i=0; i<20; i++)
{
usleep(50000);
write(dev->fd, "*OPC?\n", 6);
if(read(dev->fd, str, 128) == 2)
{
if(str[0] == '1')
{
break;
}
}
}
}
return size - 1; return size - 1;
} }