kopia lustrzana https://gitlab.com/Teuniz/DSRemote
Work in progress.
rodzic
58e697a826
commit
0a40bc26d8
2
global.h
2
global.h
|
@ -31,7 +31,7 @@
|
|||
|
||||
|
||||
#define PROGRAM_NAME "DSRemote"
|
||||
#define PROGRAM_VERSION "0.20_1506271641"
|
||||
#define PROGRAM_VERSION "0.20_1506271933"
|
||||
|
||||
#define MAX_PATHLEN 4096
|
||||
|
||||
|
|
28
tmc_dev.c
28
tmc_dev.c
|
@ -96,9 +96,10 @@ void tmcdev_close(struct tmcdev *dev)
|
|||
|
||||
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)
|
||||
{
|
||||
|
@ -119,6 +120,11 @@ int tmcdev_write(struct tmcdev *dev, const char *cmd)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if(cmd[strlen(cmd) - 1] == '?')
|
||||
{
|
||||
qry = 1;
|
||||
}
|
||||
|
||||
strncpy(buf, cmd, MAX_CMD_LEN);
|
||||
|
||||
buf[MAX_CMD_LEN] = 0;
|
||||
|
@ -146,6 +152,24 @@ int tmcdev_write(struct tmcdev *dev, const char *cmd)
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue