Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor cleanup in example code #818

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ install
/doc/latex
/doc/html
tags
.vscode/
36 changes: 19 additions & 17 deletions osal/macosx/osal.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include <string.h>
#include <osal.h>

#define USECS_PER_SEC 1000000
#define USECS_PER_SEC (1000000)

int osal_usleep (uint32 usec)
int osal_usleep(uint32 usec)
{
struct timespec ts;
ts.tv_sec = usec / USECS_PER_SEC;
Expand All @@ -25,7 +25,7 @@ int osal_gettimeofday(struct timeval *tv, struct timezone *tz)
{
struct timespec ts;
int return_value;
(void)tz; /* Not used */
(void)tz; /* Not used */

/* Use clock_gettime to prevent possible live-lock.
* Gettimeofday uses CLOCK_REALTIME that can get NTP timeadjust.
Expand All @@ -50,17 +50,19 @@ ec_timet osal_current_time(void)

void osal_time_diff(ec_timet *start, ec_timet *end, ec_timet *diff)
{
if (end->usec < start->usec) {
if (end->usec < start->usec)
{
diff->sec = end->sec - start->sec - 1;
diff->usec = end->usec + 1000000 - start->usec;
}
else {
else
{
diff->sec = end->sec - start->sec;
diff->usec = end->usec - start->usec;
}
}

void osal_timer_start(osal_timert * self, uint32 timeout_usec)
void osal_timer_start(osal_timert *self, uint32 timeout_usec)
{
struct timeval start_time;
struct timeval timeout;
Expand All @@ -75,7 +77,7 @@ void osal_timer_start(osal_timert * self, uint32 timeout_usec)
self->stop_time.usec = stop_time.tv_usec;
}

boolean osal_timer_is_expired (osal_timert * self)
boolean osal_timer_is_expired(osal_timert *self)
{
struct timeval current_time;
struct timeval stop_time;
Expand All @@ -101,15 +103,15 @@ void osal_free(void *ptr)

int osal_thread_create(void *thandle, int stacksize, void *func, void *param)
{
int ret;
pthread_attr_t attr;
pthread_t *threadp;
int ret;
pthread_attr_t attr;
pthread_t *threadp;

threadp = thandle;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, stacksize);
ret = pthread_create(threadp, &attr, func, param);
if(ret < 0)
if (ret < 0)
{
return 0;
}
Expand All @@ -118,24 +120,24 @@ int osal_thread_create(void *thandle, int stacksize, void *func, void *param)

int osal_thread_create_rt(void *thandle, int stacksize, void *func, void *param)
{
int ret;
pthread_attr_t attr;
struct sched_param schparam;
pthread_t *threadp;
int ret;
pthread_attr_t attr;
struct sched_param schparam;
pthread_t *threadp;

threadp = thandle;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, stacksize);
ret = pthread_create(threadp, &attr, func, param);
pthread_attr_destroy(&attr);
if(ret < 0)
if (ret < 0)
{
return 0;
}
memset(&schparam, 0, sizeof(schparam));
schparam.sched_priority = 40;
ret = pthread_setschedparam(*threadp, SCHED_FIFO, &schparam);
if(ret < 0)
if (ret < 0)
{
return 0;
}
Expand Down
7 changes: 4 additions & 3 deletions soem/ethercatconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ static int ecx_map_sii(ecx_contextt *context, uint16 slave)
}
context->slavelist[slave].Obits = (uint16)Osize;
context->slavelist[slave].Ibits = (uint16)Isize;
EC_PRINT(" ISIZE:%d %d OSIZE:%d\n",
EC_PRINT(" SII ISIZE:%d %d OSIZE:%d\n",
context->slavelist[slave].Ibits, Isize,context->slavelist[slave].Obits);

return 1;
Expand Down Expand Up @@ -907,7 +907,7 @@ static void ecx_config_create_input_mappings(ecx_contextt *context, void *pIOmap
uint16 configadr;
uint8 FMMUc;

EC_PRINT(" =Slave %d, INPUT MAPPING\n", slave);
EC_PRINT(" INPUT MAPPING\n");

configadr = context->slavelist[slave].configadr;
FMMUc = context->slavelist[slave].FMMUunused;
Expand Down Expand Up @@ -1024,7 +1024,8 @@ static void ecx_config_create_input_mappings(ecx_contextt *context, void *pIOmap
}
context->slavelist[slave].Istartbit =
context->slavelist[slave].FMMU[FMMUc].LogStartbit;
EC_PRINT(" Inputs %p startbit %d\n",
EC_PRINT(" slave %d Inputs %p startbit %d\n",
slave,
context->slavelist[slave].inputs,
context->slavelist[slave].Istartbit);
}
Expand Down
Loading