Skip to content

Commit

Permalink
fixed linux warnings, removed unused/unsed and set variales. Moved fs…
Browse files Browse the repository at this point in the history
…hort-wchar to machine .mk files
  • Loading branch information
nakarlsson committed Mar 17, 2015
1 parent 6afd2f5 commit c9bbb90
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 36 deletions.
2 changes: 1 addition & 1 deletion make/compilers/arm-eabi-gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ include $(PRJ_ROOT)/make/compilers/gcc.mk
MACHINE ?= -mthumb-interwork -mlittle-endian -mthumb

# Compiler flags
CFLAGS += $(MACHINE)
CFLAGS += $(MACHINE) -fshort-wchar
LDFLAGS += $(MACHINE) -Wl,--no-wchar-size-warning
2 changes: 1 addition & 1 deletion make/compilers/bfin-elf-gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ include $(PRJ_ROOT)/make/compilers/gcc.mk
MACHINE ?= -mcpu=bf537

# Compiler flags
CFLAGS += $(MACHINE)
CFLAGS += $(MACHINE) -fshort-wchar
LDFLAGS += $(MACHINE)
2 changes: 1 addition & 1 deletion make/compilers/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CC_INC_PATH = $(GCC_PATH)/$(CROSS_GCC)/include

# Compiler flags
CFLAGS = -Wall -Wextra -Wno-unused-parameter #-Werror
CFLAGS += -fomit-frame-pointer -fno-strict-aliasing -fshort-wchar
CFLAGS += -fomit-frame-pointer -fno-strict-aliasing
CFLAGS += -B$(GCC_PATH)/libexec/gcc

# Compiler C++ flags
Expand Down
2 changes: 1 addition & 1 deletion make/compilers/powerpc-eabi-gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ include $(PRJ_ROOT)/make/compilers/gcc.mk
MACHINE ?= -mbig -mregnames -mcpu=powerpc -mcall-sysv -meabi

# Compiler flags
CFLAGS += $(MACHINE)
CFLAGS += $(MACHINE) -fshort-wchar
LDFLAGS += $(MACHINE)

2 changes: 1 addition & 1 deletion make/compilers/powerpc-eabispe-gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ include $(PRJ_ROOT)/make/compilers/gcc.mk
MACHINE ?= -mcpu=8540 -mregnames -mmultiple -mabi=spe

# Compiler flags
CFLAGS += $(MACHINE)
CFLAGS += $(MACHINE) -fshort-wchar
LDFLAGS += $(MACHINE)

14 changes: 6 additions & 8 deletions test/linux/ebox/ebox.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,13 @@ void ecatthread( void *ptr )
{
struct timespec ts;
struct timeval tp;
int rc;
int ht;
int i;
int pcounter = 0;
int64 cycletime;

rc = pthread_mutex_lock(&mutex);
rc = gettimeofday(&tp, NULL);
pthread_mutex_lock(&mutex);
gettimeofday(&tp, NULL);

/* Convert from timeval to timespec */
ts.tv_sec = tp.tv_sec;
Expand All @@ -302,10 +301,10 @@ void ecatthread( void *ptr )
/* calculate next cycle start */
add_timespec(&ts, cycletime + toff);
/* wait to cycle start */
rc = pthread_cond_timedwait(&cond, &mutex, &ts);
pthread_cond_timedwait(&cond, &mutex, &ts);
if (dorun>0)
{
rc = gettimeofday(&tp, NULL);
gettimeofday(&tp, NULL);

ec_send_processdata();

Expand Down Expand Up @@ -345,7 +344,6 @@ void ecatthread( void *ptr )

int main(int argc, char *argv[])
{
int iret1;
int ctime;
struct sched_param param;
int policy = SCHED_OTHER;
Expand All @@ -371,11 +369,11 @@ int main(int argc, char *argv[])
else
ctime = 1000; // 1ms cycle time
/* create RT thread */
iret1 = pthread_create( &thread1, NULL, (void *) &ecatthread, (void*) &ctime);
pthread_create( &thread1, NULL, (void *) &ecatthread, (void*) &ctime);
memset(&param, 0, sizeof(param));
/* give it higher priority */
param.sched_priority = 40;
iret1 = pthread_setschedparam(thread1, policy, &param);
pthread_setschedparam(thread1, policy, &param);

/* start acyclic part */
eboxtest(argv[1]);
Expand Down
22 changes: 10 additions & 12 deletions test/linux/eepromtool/eepromtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ int output_intelhex(char *fname, int length)

int eeprom_read(int slave, int start, int length)
{
int i, wkc, ainc = 4;
int i, ainc = 4;
uint16 estat, aiadr;
uint32 b4;
uint64 b8;
Expand All @@ -221,13 +221,13 @@ int eeprom_read(int slave, int start, int length)
{
aiadr = 1 - slave;
eepctl = 2;
wkc = ec_APWR(aiadr, ECT_REG_EEPCFG, sizeof(eepctl), &eepctl , EC_TIMEOUTRET); /* force Eeprom from PDI */
ec_APWR(aiadr, ECT_REG_EEPCFG, sizeof(eepctl), &eepctl , EC_TIMEOUTRET); /* force Eeprom from PDI */
eepctl = 0;
wkc = ec_APWR(aiadr, ECT_REG_EEPCFG, sizeof(eepctl), &eepctl , EC_TIMEOUTRET); /* set Eeprom to master */
ec_APWR(aiadr, ECT_REG_EEPCFG, sizeof(eepctl), &eepctl , EC_TIMEOUTRET); /* set Eeprom to master */

estat = 0x0000;
aiadr = 1 - slave;
wkc=ec_APRD(aiadr, ECT_REG_EEPSTAT, sizeof(estat), &estat, EC_TIMEOUTRET); /* read eeprom status */
ec_APRD(aiadr, ECT_REG_EEPSTAT, sizeof(estat), &estat, EC_TIMEOUTRET); /* read eeprom status */
estat = etohs(estat);
if (estat & EC_ESTAT_R64)
{
Expand Down Expand Up @@ -265,24 +265,23 @@ int eeprom_read(int slave, int start, int length)

int eeprom_write(int slave, int start, int length)
{
int i, wkc, dc = 0;
int i, dc = 0;
uint16 aiadr, *wbuf;
uint8 eepctl;
int ret;

if((ec_slavecount >= slave) && (slave > 0) && ((start + length) <= MAXBUF))
{
aiadr = 1 - slave;
eepctl = 2;
wkc = ec_APWR(aiadr, ECT_REG_EEPCFG, sizeof(eepctl), &eepctl , EC_TIMEOUTRET); /* force Eeprom from PDI */
ec_APWR(aiadr, ECT_REG_EEPCFG, sizeof(eepctl), &eepctl , EC_TIMEOUTRET); /* force Eeprom from PDI */
eepctl = 0;
wkc = ec_APWR(aiadr, ECT_REG_EEPCFG, sizeof(eepctl), &eepctl , EC_TIMEOUTRET); /* set Eeprom to master */
ec_APWR(aiadr, ECT_REG_EEPCFG, sizeof(eepctl), &eepctl , EC_TIMEOUTRET); /* set Eeprom to master */

aiadr = 1 - slave;
wbuf = (uint16 *)&ebuf[0];
for (i = start ; i < (start + length) ; i+=2)
{
ret = ec_writeeepromAP(aiadr, i >> 1 , *(wbuf + (i >> 1)), EC_TIMEOUTEEP);
ec_writeeepromAP(aiadr, i >> 1 , *(wbuf + (i >> 1)), EC_TIMEOUTEEP);
if (++dc >= 100)
{
dc = 0;
Expand All @@ -299,7 +298,6 @@ int eeprom_write(int slave, int start, int length)

int eeprom_writealias(int slave, int alias, uint16 crc)
{
int wkc;
uint16 aiadr;
uint8 eepctl;
int ret;
Expand All @@ -308,9 +306,9 @@ int eeprom_writealias(int slave, int alias, uint16 crc)
{
aiadr = 1 - slave;
eepctl = 2;
wkc = ec_APWR(aiadr, ECT_REG_EEPCFG, sizeof(eepctl), &eepctl , EC_TIMEOUTRET); /* force Eeprom from PDI */
ec_APWR(aiadr, ECT_REG_EEPCFG, sizeof(eepctl), &eepctl , EC_TIMEOUTRET); /* force Eeprom from PDI */
eepctl = 0;
wkc = ec_APWR(aiadr, ECT_REG_EEPCFG, sizeof(eepctl), &eepctl , EC_TIMEOUTRET); /* set Eeprom to master */
ec_APWR(aiadr, ECT_REG_EEPCFG, sizeof(eepctl), &eepctl , EC_TIMEOUTRET); /* set Eeprom to master */

ret = ec_writeeepromAP(aiadr, 0x04 , alias, EC_TIMEOUTEEP);
if (ret)
Expand Down
11 changes: 4 additions & 7 deletions test/linux/red_test/red_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,10 @@ void ec_sync(int64 reftime, int64 cycletime , int64 *offsettime)
OSAL_THREAD_FUNC_RT ecatthread(void *ptr)
{
struct timespec ts, tleft;
struct timeval tp;
int rc;
int ht;
int64 cycletime;

rc = clock_gettime(CLOCK_MONOTONIC, &ts);
clock_gettime(CLOCK_MONOTONIC, &ts);
ht = (ts.tv_nsec / 1000000) + 1; /* round to nearest ms */
ts.tv_nsec = ht * 1000000;
cycletime = *(int*)ptr * 1000; /* cycletime in ns */
Expand All @@ -214,7 +212,7 @@ OSAL_THREAD_FUNC_RT ecatthread(void *ptr)
/* calculate next cycle start */
add_timespec(&ts, cycletime + toff);
/* wait to cycle start */
rc = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, &tleft);
clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, &tleft);
if (dorun>0)
{
wkc = ec_receive_processdata(EC_TIMEOUTRET);
Expand Down Expand Up @@ -313,7 +311,6 @@ OSAL_THREAD_FUNC ecatcheck( void *ptr )

int main(int argc, char *argv[])
{
int iret1, iret2;
int ctime;

printf("SOEM (Simple Open EtherCAT Master)\nRedundancy test\n");
Expand All @@ -324,10 +321,10 @@ int main(int argc, char *argv[])
ctime = atoi(argv[3]);

/* create RT thread */
iret1 = osal_thread_create_rt(&thread1, stack64k * 2, &ecatthread, (void*) &ctime);
osal_thread_create_rt(&thread1, stack64k * 2, &ecatthread, (void*) &ctime);

/* create thread to handle slave error handling in OP */
iret2 = osal_thread_create(&thread2, stack64k * 4, &ecatcheck, NULL);
osal_thread_create(&thread2, stack64k * 4, &ecatcheck, NULL);

/* start acyclic part */
redtest(argv[1],argv[2]);
Expand Down
6 changes: 2 additions & 4 deletions test/linux/simple_test/simple_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ uint8 currentgroup = 0;

void simpletest(char *ifname)
{
int i, j, oloop, iloop, wkc_count, chk;
int i, j, oloop, iloop, chk;
needlf = FALSE;
inOP = FALSE;

Expand Down Expand Up @@ -92,7 +92,6 @@ void simpletest(char *ifname)
if (ec_slave[0].state == EC_STATE_OPERATIONAL )
{
printf("Operational state reached for all slaves.\n");
wkc_count = 0;
inOP = TRUE;
/* cyclic loop */
for(i = 1; i <= 10000; i++)
Expand Down Expand Up @@ -232,13 +231,12 @@ OSAL_THREAD_FUNC ecatcheck( void *ptr )

int main(int argc, char *argv[])
{
int iret1;
printf("SOEM (Simple Open EtherCAT Master)\nSimple test\n");

if (argc > 1)
{
/* create thread to handle slave error handling in OP */
// iret1 = pthread_create( &thread1, NULL, (void *) &ecatcheck, (void*) &ctime);
// pthread_create( &thread1, NULL, (void *) &ecatcheck, (void*) &ctime);
osal_thread_create(&thread1, 128000, &ecatcheck, (void*) &ctime);
/* start cyclic part */
simpletest(argv[1]);
Expand Down

0 comments on commit c9bbb90

Please sign in to comment.