Minor cleanup in the test applications

pull/7/head
Mikael Heden 2015-07-09 17:58:54 +02:00
parent 77da52b89d
commit d6dd3411d7
5 changed files with 39 additions and 35 deletions

View File

@ -1,6 +0,0 @@
<?xml version="1.0"?>
<gtodo>
<category title="Personal" place="0"/>
<category title="Business" place="1"/>
<category title="Unfiled" place="2"/>
</gtodo>

View File

@ -42,7 +42,7 @@ typedef double float64;
typedef struct
{
uint32 sec; /*< Seconds elapsed since the Epoch (Jan 1, 1970) */
int32 usec; /*< Microseconds elapsed since last second boundary */
uint32 usec; /*< Microseconds elapsed since last second boundary */
} ec_timet;
typedef struct osal_timer

View File

@ -17,9 +17,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
#include "ethercattype.h"
#include "nicdrv.h"
@ -51,7 +48,7 @@ uint16 ow;
int os;
int slave;
int alias;
struct timeval tstart,tend, tdif;
ec_timet tstart,tend, tdif;
int wkc;
int mode;
char sline[MAXSLENGTH];
@ -341,7 +338,7 @@ void eepromtool(char *ifname, int slave, int mode, char *fname)
{
if ((mode == MODE_INFO) || (mode == MODE_READBIN) || (mode == MODE_READINTEL))
{
rc = gettimeofday(&tstart, NULL);
tstart = osal_current_time();
eeprom_read(slave, 0x0000, MINBUF); // read first 128 bytes
wbuf = (uint16 *)&ebuf[0];
@ -366,12 +363,12 @@ void eepromtool(char *ifname, int slave, int mode, char *fname)
if (esize > MINBUF)
eeprom_read(slave, MINBUF, esize - MINBUF); // read reminder
rc = gettimeofday(&tend, NULL);
timersub(&tend, &tstart, &tdif);
tend = osal_current_time();
osal_time_diff(&tstart, &tend, &tdif);
if (mode == MODE_READINTEL) output_intelhex(fname, esize);
if (mode == MODE_READBIN) output_bin(fname, esize);
printf("\nTotal EEPROM read time :%ldms\n", (tdif.tv_usec+(tdif.tv_sec*1000000L)) / 1000);
printf("\nTotal EEPROM read time :%ldms\n", (tdif.usec+(tdif.sec*1000000L)) / 1000);
}
if ((mode == MODE_WRITEBIN) || (mode == MODE_WRITEINTEL))
{
@ -390,12 +387,12 @@ void eepromtool(char *ifname, int slave, int mode, char *fname)
printf("Busy");
fflush(stdout);
rc = gettimeofday(&tstart, NULL);
tstart = osal_current_time();
eeprom_write(slave, estart, esize);
rc = gettimeofday(&tend, NULL);
timersub(&tend, &tstart, &tdif);
tend = osal_current_time();
osal_time_diff(&tstart, &tend, &tdif);
printf("\nTotal EEPROM write time :%ldms\n", (tdif.tv_usec+(tdif.tv_sec*1000000L)) / 1000);
printf("\nTotal EEPROM write time :%ldms\n", (tdif.usec+(tdif.sec*1000000L)) / 1000);
}
else
printf("Error reading file, abort.\n");

View File

@ -11,9 +11,6 @@
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <pthread.h>
#include "ethercattype.h"
#include "nicdrv.h"
@ -116,7 +113,7 @@ void simpletest(char *ifname)
printf(" T:%lld\r",ec_DCtime);
needlf = TRUE;
}
usleep(5000);
osal_usleep(5000);
}
inOP = FALSE;
@ -225,7 +222,7 @@ OSAL_THREAD_FUNC ecatcheck( void *ptr )
if(!ec_group[currentgroup].docheckstate)
printf("OK : all slaves resumed OPERATIONAL.\n");
}
usleep(10000);
osal_usleep(10000);
}
}

View File

@ -420,12 +420,16 @@ int si_siiPDO(uint16 slave, uint8 t, int mapoffset, int bitoffset)
PDO->BitSize[PDO->nPDO] += bitlen;
a += 2;
str_name[0] = 0;
if(obj_name)
ec_siistring(str_name, slave, obj_name);
/* skip entry if filler (0x0000:0x00) */
if(obj_idx || obj_subidx)
{
str_name[0] = 0;
if(obj_name)
ec_siistring(str_name, slave, obj_name);
printf(" [0x%4.4X.%1d] 0x%4.4X:0x%2.2X 0x%2.2X", abs_offset, abs_bit, obj_idx, obj_subidx, bitlen);
printf(" %-12s %s\n", dtype2string(obj_datatype), str_name);
printf(" [0x%4.4X.%1d] 0x%4.4X:0x%2.2X 0x%2.2X", abs_offset, abs_bit, obj_idx, obj_subidx, bitlen);
printf(" %-12s %s\n", dtype2string(obj_datatype), str_name);
}
bitoffset += bitlen;
totalsize += bitlen;
}
@ -619,22 +623,34 @@ void slaveinfo(char *ifname)
}
}
char ifbuf[1024];
int main(int argc, char *argv[])
{
ec_adaptert * adapter = NULL;
printf("SOEM (Simple Open EtherCAT Master)\nSlaveinfo\n");
if (argc > 1)
{
{
if ((argc > 2) && (strncmp(argv[2], "-sdo", sizeof("-sdo")) == 0)) printSDO = TRUE;
if ((argc > 2) && (strncmp(argv[2], "-map", sizeof("-map")) == 0)) printMAP = TRUE;
/* start slaveinfo */
slaveinfo(argv[1]);
strcpy(ifbuf, argv[1]);
slaveinfo(ifbuf);
}
else
{
printf("Usage: slaveinfo ifname [options]\nifname = eth0 for example\nOptions :\n -sdo : print SDO info\n -map : print mapping\n");
}
printf("Usage: slaveinfo ifname [options]\nifname = eth0 for example\nOptions :\n -sdo : print SDO info\n -map : print mapping\n");
printf ("Available adapters\n");
adapter = ec_find_adapters ();
while (adapter != NULL)
{
printf ("Description : %s, Device to use for wpcap: %s\n", adapter->desc,adapter->name);
adapter = adapter->next;
}
}
printf("End program\n");
return (0);
}