Compare commits

...

26 Commits

Author SHA1 Message Date
ArthurKetels 342ca8632c
Merge pull request #460 from OpenEtherCATsociety/ArthurKetels-add_timespec
Arthur ketels add timespec
2020-11-09 22:46:25 +01:00
ArthurKetels 2c1b9b2756
Update red_test.c 2020-11-09 22:41:50 +01:00
ArthurKetels 4b4cdc2c45
Fix add_timespec 2020-11-09 22:39:56 +01:00
ArthurKetels d9261e801d
Merge pull request #454 from nakarlsson/master
Fix llvm compiler implicit-int-conversion warnings
2020-10-12 22:09:27 +02:00
Andreas Karlsson 447d184d7e Fix llvm compiler implicit-int-conversion warnings
* use uint8 for idx
* make config Isize/Osize uint32
* generally, align sizes in functions to HW objects
* Fix non-standard [0] size data array in EoE struct
2020-10-12 16:24:42 +02:00
ArthurKetels b01ceb9905
Merge pull request #452 from OpenEtherCATsociety/AK-fix-SoE-mapping
Fix bug in ecx_readIDNmap(), Osize and Isize
2020-10-01 23:02:47 +02:00
ArthurKetels cbc8f36e87
Fix bug in ecx_readIDNmap(), Osize and Isize
Osize and Isize where reset to 16 at every new drive number, thus loosing all lower drive mapping data. Changed to add 16 to Osize and Isize.
2020-10-01 23:00:01 +02:00
ArthurKetels f69b1ab702
Merge pull request #436 from nakarlsson/master
Don't always include optional IP parameter lengths
2020-08-18 15:56:47 +02:00
Andreas Karlsson 101ac54a7d Don't always include optional IP parameter lengths
Obvious fix, the optional IP parameters length should
only be included in total length if they are included.

fixes #421
2020-08-18 15:47:36 +02:00
ArthurKetels f938df6bac
Merge pull request #435 from OpenEtherCATsociety/revert-431-master
Revert "EoE and Distributed clock fixes"
2020-08-18 15:40:50 +02:00
nakarlsson bb82fc33d7
Revert "EoE and Distributed clock fixes" 2020-08-18 14:56:16 +02:00
Hans-Erik Floryd 08d480cf82
Merge pull request #431 from nakarlsson/master
EoE and Distributed clock fixes
2020-08-17 09:07:40 +02:00
Andreas Karlsson 33aa7a3c57 Correct unit for dc mastertime calulcation to (ns)
The correct factor for seconds should be 1000000000

fixes #432
2020-08-16 11:25:13 +02:00
Andreas Karlsson bae37b9028 Don't always include optional IP parameter lengths
Obvious fix, the optional IP parameters length should
only be included in total length if they are included.

fixes #421
2020-08-16 11:20:10 +02:00
Pedram Nimreezi 953eb07f8a Update printf statement
Just happened to spot this
2020-05-09 13:49:17 +02:00
berkaydeniz 63d699d303 assert is removed from macos version of nicdrv.c
As discussed in Issue #392, this assert only exists for macos and is an overkill.
2020-05-09 13:46:44 +02:00
Andreas Karlsson 093311561c Limit expected working counter per ESC
Add one to the expected working counter per
ESC/Slave, not for every syncmanager/fmmu.
Use case, if the slave define more input/output
syncmanager/fmmus it still only generate maximum
working counter of 3 for a RW command.

fixes 374
2020-03-03 11:30:55 +01:00
seanyen 7fe05b5b4b Improved SOEM portability.
* Replaced CMAKE_SOURCE_DIR with CMAKE_CURRENT_LIST_DIR to make SOEM CMakeLists.txt more relocatable.
* Installed SOEM CMake config files to a more universal location to search.
2020-01-07 16:08:50 +01:00
Arthur Ketels 92ff466357 Fix ecx_pushindex, remove DCtO and DCl from ecx_context 2019-11-13 21:03:56 +01:00
Arthur Ketels 9ec8635943 Fix tx/rx processdata functions 2019-11-12 17:03:48 +01:00
Hans-Erik Floryd 2a8c07c32b
Merge pull request #348 from jjguti/feature/run-on-newer-gcc
run on newer gcc
2019-10-21 12:11:55 +02:00
Hans-Erik Floryd f8b0029765
Merge pull request #347 from jjguti/master
fix warning with strncpy on newer GCC's
2019-10-21 12:11:36 +02:00
Juanjo Gutiérrez 7bb27de2a2 testing on newer gccs and macosx
this patch adds building on ubuntu bionic that has a newer gcc while
keeping ubuntu xenial (default on travis-ci)

it also adds macosx since it was very easy to add and it's a platform we can build for
2019-10-20 22:27:00 +02:00
Juanjo Gutiérrez cffd3ba283 fix warning with strncpy on newer GCC versions
strncpy should not be called with a "length" parameter which is based on
the source string since it negates the benefits of using strncpy. this
patch fixes the warning for linux, macosx and rtems

Fixes #346
Change-Id: Ib2fb7637e9845545e4c15045e6be7c7ce8e0672b
2019-10-18 15:31:57 +02:00
Giuseppe Iellamo 09d48acc32 Update to CMakeLists.txt 2019-10-08 14:14:47 +02:00
nakarlsson abbf0d42e3
Fix doxygen build warnings for SOEM 1.4.0 (#312)
Trvial non-code changes
2019-06-13 08:06:41 +02:00
40 changed files with 524 additions and 515 deletions

View File

@ -1,3 +1,9 @@
jobs:
include:
- dist: xenial
- dist: bionic
- os: osx
language: c
script:

View File

@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 2.8.4)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")
cmake_minimum_required(VERSION 2.8.12)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules")
project(SOEM C)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# Default to installing in SOEM source directory
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/install)
endif()
set(SOEM_INCLUDE_INSTALL_DIR include/soem)
@ -15,9 +15,9 @@ if(WIN32)
set(OS "win32")
include_directories(oshw/win32/wpcap/Include)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
link_directories(${CMAKE_SOURCE_DIR}/oshw/win32/wpcap/Lib/x64)
link_directories(${CMAKE_CURRENT_LIST_DIR}/oshw/win32/wpcap/Lib/x64)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
link_directories(${CMAKE_SOURCE_DIR}/oshw/win32/wpcap/Lib)
link_directories(${CMAKE_CURRENT_LIST_DIR}/oshw/win32/wpcap/Lib)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_NO_WARNINGS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
@ -60,11 +60,6 @@ file(GLOB SOEM_HEADERS soem/*.h)
file(GLOB OSAL_HEADERS osal/osal.h osal/${OS}/*.h)
file(GLOB OSHW_HEADERS oshw/${OS}/*.h)
include_directories(soem)
include_directories(osal)
include_directories(osal/${OS})
include_directories(oshw/${OS})
add_library(soem STATIC
${SOEM_SOURCES}
${OSAL_SOURCES}
@ -72,9 +67,29 @@ add_library(soem STATIC
${OSHW_EXTRA_SOURCES})
target_link_libraries(soem ${OS_LIBS})
target_include_directories(soem PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/soem>
$<INSTALL_INTERFACE:include/soem>)
target_include_directories(soem PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/osal>
$<INSTALL_INTERFACE:include/soem>)
target_include_directories(soem PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/osal/${OS}>
$<INSTALL_INTERFACE:include/soem>)
target_include_directories(soem
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/oshw/${OS}>
$<INSTALL_INTERFACE:include/soem>
)
message("LIB_DIR: ${SOEM_LIB_INSTALL_DIR}")
install(TARGETS soem DESTINATION ${SOEM_LIB_INSTALL_DIR})
install(TARGETS soem EXPORT soemConfig DESTINATION ${SOEM_LIB_INSTALL_DIR})
install(EXPORT soemConfig DESTINATION share/soem/cmake)
install(FILES
${SOEM_HEADERS}
${OSAL_HEADERS}

View File

@ -1,7 +1,7 @@
/**
* \mainpage Simple Open EtherCAT Master or SOEM
*
* \section start Tutorial
* \section tutorial Tutorial
* For a tutorial on SOEM See tutorial.txt
*
* \section overview Overview

View File

@ -231,11 +231,11 @@ Below is an example on how to assign a slave to a group. <b>OBS!</b> A slave can
{
if ( <some condition> )
{
ec_slave[cnt].group = <X>;
ec_slave[cnt].group = X;
}
else
{
ec_slave[cnt].group = <Y>;
ec_slave[cnt].group = Y;
}
}
\endcode
@ -247,12 +247,12 @@ This option will share IOmap and store the group IOmap data at offset EC_LOGGROU
ec_config_map_group(&IOmap, 0);
\endcode
Alternative 2, configure the slave groups one by one, call ec_config_map or ec_config_map_group with arg <X>, <Y>.
Alternative 2, configure the slave groups one by one, call ec_config_map or ec_config_map_group with arg X, Y.
This option will use different, supplied by the user, IOmaps.
\code
ec_config_map_group(&IOmap1, <X>);
ec_config_map_group(&IOmap2, <Y>);
ec_config_map_group(&IOmap1, X);
ec_config_map_group(&IOmap2, Y);
\endcode
To exchange process data for given group(s) the user must call send/recv process data per group.
@ -260,10 +260,10 @@ The send and receive stack of process data don't consider groups, so the applica
and receive the process data for one group before sending/receiving process data for another group.
\code
ec_send_processdata_group(<X>);
ec_receive_processdata_group(<X>, EC_TIMEOUTRET);
ec_send_processdata_group(<Y>);
ec_receive_processdata_group(<Y>, EC_TIMEOUTRET);
ec_send_processdata_group(X);
ec_receive_processdata_group(X, EC_TIMEOUTRET);
ec_send_processdata_group(Y);
ec_receive_processdata_group(Y, EC_TIMEOUTRET);
\endcode
\section application Application

View File

@ -165,10 +165,10 @@ void ec_setupheader(void *p)
* @param[in] port = port context struct
* @return new index.
*/
int ecx_getindex(ecx_portt *port)
uint8 ecx_getindex(ecx_portt *port)
{
int idx;
int cnt = 0;
uint8 idx;
uint8 cnt = 0;
ee_port_lock();
@ -199,7 +199,7 @@ int ecx_getindex(ecx_portt *port)
* @param[in] idx = index in buffer array
* @param[in] bufstat = status to set
*/
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat)
{
port->rxbufstat[idx] = bufstat;
if (port->redstate != ECT_RED_NONE)
@ -212,7 +212,7 @@ void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
* @param[in] stacknumber = 0=Primary 1=Secondary stack
* @return socket send result
*/
int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
int ecx_outframe(ecx_portt *port, uint8 idx, int stacknumber)
{
int lp;
ec_stackT *stack;
@ -234,7 +234,7 @@ int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
* @param[in] idx = index in tx buffer array
* @return socket send result
*/
int ecx_outframe_red(ecx_portt *port, int idx)
int ecx_outframe_red(ecx_portt *port, uint8 idx)
{
ec_comt *datagramP;
ec_etherheadert *ehp;
@ -300,11 +300,11 @@ static int ecx_recvpkt(ecx_portt *port, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME or EC_OTHERFRAME.
*/
int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
int ecx_inframe(ecx_portt *port, uint8 idx, int stacknumber)
{
uint16 l;
int rval;
int idxf;
uint8 idxf;
ec_etherheadert *ehp;
ec_comt *ecp;
ec_stackT *stack;
@ -389,7 +389,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
static int ecx_waitinframe_red(ecx_portt *port, uint8 idx, osal_timert *timer)
{
osal_timert timer2;
int wkc = EC_NOFRAME;
@ -464,7 +464,7 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout)
{
int wkc;
osal_timert timer;
@ -487,7 +487,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
* @param[in] timeout = timeout in us
* @return Workcounter or EC_NOFRAME
*/
int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
int ecx_srconfirm(ecx_portt *port, uint8 idx, int timeout)
{
int wkc = EC_NOFRAME;
osal_timert timer1, timer2;
@ -529,32 +529,32 @@ int ec_getindex(void)
return ecx_getindex(&ecx_port);
}
void ec_setbufstat(int idx, int bufstat)
void ec_setbufstat(uint8 idx, int bufstat)
{
ecx_setbufstat(&ecx_port, idx, bufstat);
}
int ec_outframe(int idx, int stacknumber)
int ec_outframe(uint8 idx, int stacknumber)
{
return ecx_outframe(&ecx_port, idx, stacknumber);
}
int ec_outframe_red(int idx)
int ec_outframe_red(uint8 idx)
{
return ecx_outframe_red(&ecx_port, idx);
}
int ec_inframe(int idx, int stacknumber)
int ec_inframe(uint8 idx, int stacknumber)
{
return ecx_inframe(&ecx_port, idx, stacknumber);
}
int ec_waitinframe(int idx, int timeout)
int ec_waitinframe(uint8 idx, int timeout)
{
return ecx_waitinframe(&ecx_port, idx, timeout);
}
int ec_srconfirm(int idx, int timeout)
int ec_srconfirm(uint8 idx, int timeout)
{
return ecx_srconfirm(&ecx_port, idx, timeout);
}

View File

@ -73,7 +73,7 @@ typedef struct
/** temporary tx buffer length */
int txbuflength2;
/** last used frame index */
int lastidx;
uint8 lastidx;
/** current redundancy state */
int redstate;
/** pointer to redundancy port and buffers */
@ -94,26 +94,26 @@ extern ecx_redportt ecx_redport;
int ec_setupnic(const char * ifname, int secondary);
int ec_closenic(void);
void ec_setbufstat(int idx, int bufstat);
int ec_getindex(void);
int ec_outframe(int idx, int sock);
int ec_outframe_red(int idx);
int ec_waitinframe(int idx, int timeout);
int ec_srconfirm(int idx,int timeout);
int ec_inframe(int idx, int stacknumber);
void ec_setbufstat(uint8 idx, int bufstat);
uint8 ec_getindex(void);
int ec_outframe(uint8 idx, int sock);
int ec_outframe_red(uint8 idx);
int ec_waitinframe(uint8 idx, int timeout);
int ec_srconfirm(uint8 idx,int timeout);
int ec_inframe(uint8 idx, int stacknumber);
#endif
void ec_setupheader(void *p);
int ecx_setupnic(ecx_portt *port, const char *ifname, int secondary);
int ecx_closenic(ecx_portt *port);
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat);
int ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, int idx, int sock);
int ecx_outframe_red(ecx_portt *port, int idx);
int ecx_waitinframe(ecx_portt *port, int idx, int timeout);
int ecx_srconfirm(ecx_portt *port, int idx,int timeout);
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat);
uint8 ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, uint8 idx, int sock);
int ecx_outframe_red(ecx_portt *port, uint8 idx);
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout);
int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout);
int ecx_inframe(ecx_portt *port, int idx, int stacknumber);
int ecx_inframe(ecx_portt *port, uint8 idx, int stacknumber);
#ifdef __cplusplus
}

View File

@ -267,10 +267,10 @@ void ec_setupheader(void *p)
/** Get new frame identifier index and allocate corresponding rx buffer.
* @return new index.
*/
int ecx_getindex(ecx_portt *port)
uint8 ecx_getindex(ecx_portt *port)
{
uint8 idx;
int cnt;
uint8 cnt;
WaitForRtControl(port->getindex_region);
@ -307,7 +307,7 @@ int ecx_getindex(ecx_portt *port)
* @param[in] idx = index in buffer array
* @param[in] bufstat = status to set
*/
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat)
{
port->rxbufstat[idx] = bufstat;
if (port->redstate != ECT_RED_NONE)
@ -321,7 +321,7 @@ void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
* @param[in] stacknumber = 0=Primary 1=Secondary stack
* @return socket send result
*/
int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
int ecx_outframe(ecx_portt *port, uint8 idx, int stacknumber)
{
HPESTATUS status;
DWORD txstate;
@ -384,7 +384,7 @@ end:
* @param[in] idx = index in tx buffer array
* @return socket send result
*/
int ecx_outframe_red(ecx_portt *port, int idx)
int ecx_outframe_red(ecx_portt *port, uint8 idx)
{
HPESTATUS status;
ec_comt *datagramP;
@ -471,7 +471,7 @@ static int ecx_recvpkt(ecx_portt *port, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME or EC_OTHERFRAME.
*/
int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
int ecx_inframe(ecx_portt *port, uint8 idx, int stacknumber)
{
uint16 l;
int rval;
@ -560,7 +560,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
static int ecx_waitinframe_red(ecx_portt *port, uint8 idx, osal_timert *timer)
{
osal_timert timer2;
int wkc = EC_NOFRAME;
@ -646,7 +646,7 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout)
{
int wkc;
osal_timert timer;
@ -681,7 +681,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
* @param[in] timeout = timeout in us
* @return Workcounter or EC_NOFRAME
*/
int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
int ecx_srconfirm(ecx_portt *port, uint8 idx, int timeout)
{
int wkc = EC_NOFRAME;
osal_timert timer1;
@ -706,37 +706,37 @@ int ec_closenic(void)
return ecx_closenic(&ecx_port);
}
int ec_getindex(void)
uint8 ec_getindex(void)
{
return ecx_getindex(&ecx_port);
}
void ec_setbufstat(int idx, int bufstat)
void ec_setbufstat(uint8 idx, int bufstat)
{
ecx_setbufstat(&ecx_port, idx, bufstat);
}
int ec_outframe(int idx, int stacknumber)
int ec_outframe(uint8 idx, int stacknumber)
{
return ecx_outframe(&ecx_port, idx, stacknumber);
}
int ec_outframe_red(int idx)
int ec_outframe_red(uint8 idx)
{
return ecx_outframe_red(&ecx_port, idx);
}
int ec_inframe(int idx, int stacknumber)
int ec_inframe(uint8 idx, int stacknumber)
{
return ecx_inframe(&ecx_port, idx, stacknumber);
}
int ec_waitinframe(int idx, int timeout)
int ec_waitinframe(uint8 idx, int timeout)
{
return ecx_waitinframe(&ecx_port, idx, timeout);
}
int ec_srconfirm(int idx, int timeout)
int ec_srconfirm(uint8 idx, int timeout)
{
return ecx_srconfirm(&ecx_port, idx, timeout);
}

View File

@ -74,7 +74,7 @@ typedef struct
/** temporary tx buffer length */
int txbuflength2;
/** last used frame index */
int lastidx;
uint8 lastidx;
/** current redundancy state */
int redstate;
/** pointer to redundancy port and buffers */
@ -97,20 +97,20 @@ extern const uint16 secMAC[3];
int ec_setupnic(const char * ifname, int secondary);
int ec_closenic(void);
void ec_setupheader(void *p);
void ec_setbufstat(int idx, int bufstat);
int ec_getindex(void);
int ec_outframe(int idx, int sock);
int ec_outframe_red(int idx);
int ec_waitinframe(int idx, int timeout);
int ec_srconfirm(int idx,int timeout);
void ec_setbufstat(uint8 idx, int bufstat);
uint8 ec_getindex(void);
int ec_outframe(uint8 idx, int sock);
int ec_outframe_red(uint8 idx);
int ec_waitinframe(uint8 idx, int timeout);
int ec_srconfirm(uint8 idx,int timeout);
int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary);
int ecx_closenic(ecx_portt *port);
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat);
int ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, int idx, int sock);
int ecx_outframe_red(ecx_portt *port, int idx);
int ecx_waitinframe(ecx_portt *port, int idx, int timeout);
int ecx_srconfirm(ecx_portt *port, int idx,int timeout);
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat);
uint8 ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, uint8 idx, int sock);
int ecx_outframe_red(ecx_portt *port, uint8 idx);
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout);
int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout);
#endif

View File

@ -215,10 +215,10 @@ void ec_setupheader(void *p)
* @param[in] port = port context struct
* @return new index.
*/
int ecx_getindex(ecx_portt *port)
uint8 ecx_getindex(ecx_portt *port)
{
int idx;
int cnt;
uint8 idx;
uint8 cnt;
pthread_mutex_lock( &(port->getindex_mutex) );
@ -254,7 +254,7 @@ int ecx_getindex(ecx_portt *port)
* @param[in] idx = index in buffer array
* @param[in] bufstat = status to set
*/
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat)
{
port->rxbufstat[idx] = bufstat;
if (port->redstate != ECT_RED_NONE)
@ -267,7 +267,7 @@ void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
* @param[in] stacknumber = 0=Primary 1=Secondary stack
* @return socket send result
*/
int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
int ecx_outframe(ecx_portt *port, uint8 idx, int stacknumber)
{
int lp, rval;
ec_stackT *stack;
@ -296,7 +296,7 @@ int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
* @param[in] idx = index in tx buffer array
* @return socket send result
*/
int ecx_outframe_red(ecx_portt *port, int idx)
int ecx_outframe_red(ecx_portt *port, uint8 idx)
{
ec_comt *datagramP;
ec_etherheadert *ehp;
@ -370,11 +370,11 @@ static int ecx_recvpkt(ecx_portt *port, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME or EC_OTHERFRAME.
*/
int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
int ecx_inframe(ecx_portt *port, uint8 idx, int stacknumber)
{
uint16 l;
int rval;
int idxf;
uint8 idxf;
ec_etherheadert *ehp;
ec_comt *ecp;
ec_stackT *stack;
@ -464,7 +464,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
static int ecx_waitinframe_red(ecx_portt *port, uint8 idx, osal_timert *timer)
{
osal_timert timer2;
int wkc = EC_NOFRAME;
@ -547,7 +547,7 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout)
{
int wkc;
osal_timert timer;
@ -570,7 +570,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
* @param[in] timeout = timeout in us
* @return Workcounter or EC_NOFRAME
*/
int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
int ecx_srconfirm(ecx_portt *port, uint8 idx, int timeout)
{
int wkc = EC_NOFRAME;
osal_timert timer1, timer2;
@ -608,37 +608,37 @@ int ec_closenic(void)
return ecx_closenic(&ecx_port);
}
int ec_getindex(void)
uint8 ec_getindex(void)
{
return ecx_getindex(&ecx_port);
}
void ec_setbufstat(int idx, int bufstat)
void ec_setbufstat(uint8 idx, int bufstat)
{
ecx_setbufstat(&ecx_port, idx, bufstat);
}
int ec_outframe(int idx, int stacknumber)
int ec_outframe(uint8 idx, int stacknumber)
{
return ecx_outframe(&ecx_port, idx, stacknumber);
}
int ec_outframe_red(int idx)
int ec_outframe_red(uint8 idx)
{
return ecx_outframe_red(&ecx_port, idx);
}
int ec_inframe(int idx, int stacknumber)
int ec_inframe(uint8 idx, int stacknumber)
{
return ecx_inframe(&ecx_port, idx, stacknumber);
}
int ec_waitinframe(int idx, int timeout)
int ec_waitinframe(uint8 idx, int timeout)
{
return ecx_waitinframe(&ecx_port, idx, timeout);
}
int ec_srconfirm(int idx, int timeout)
int ec_srconfirm(uint8 idx, int timeout)
{
return ecx_srconfirm(&ecx_port, idx, timeout);
}

View File

@ -76,7 +76,7 @@ typedef struct
/** temporary tx buffer length */
int txbuflength2;
/** last used frame index */
int lastidx;
uint8 lastidx;
/** current redundancy state */
int redstate;
/** pointer to redundancy port and buffers */
@ -95,23 +95,23 @@ extern ecx_redportt ecx_redport;
int ec_setupnic(const char * ifname, int secondary);
int ec_closenic(void);
void ec_setbufstat(int idx, int bufstat);
int ec_getindex(void);
int ec_outframe(int idx, int sock);
int ec_outframe_red(int idx);
int ec_waitinframe(int idx, int timeout);
int ec_srconfirm(int idx,int timeout);
void ec_setbufstat(uint8 idx, int bufstat);
uint8 ec_getindex(void);
int ec_outframe(uint8 idx, int sock);
int ec_outframe_red(uint8 idx);
int ec_waitinframe(uint8 idx, int timeout);
int ec_srconfirm(uint8 idx,int timeout);
#endif
void ec_setupheader(void *p);
int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary);
int ecx_closenic(ecx_portt *port);
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat);
int ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, int idx, int sock);
int ecx_outframe_red(ecx_portt *port, int idx);
int ecx_waitinframe(ecx_portt *port, int idx, int timeout);
int ecx_srconfirm(ecx_portt *port, int idx,int timeout);
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat);
uint8 ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, uint8 idx, int sock);
int ecx_outframe_red(ecx_portt *port, uint8 idx);
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout);
int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout);
#ifdef __cplusplus
}

View File

@ -42,7 +42,6 @@ uint16 oshw_ntohs(uint16 network)
ec_adaptert * oshw_find_adapters(void)
{
int i;
int string_len;
struct if_nameindex *ids;
ec_adaptert * adapter;
ec_adaptert * prev_adapter;
@ -75,15 +74,10 @@ ec_adaptert * oshw_find_adapters(void)
if (ids[i].if_name)
{
string_len = strlen(ids[i].if_name);
if (string_len > (EC_MAXLEN_ADAPTERNAME - 1))
{
string_len = EC_MAXLEN_ADAPTERNAME - 1;
}
strncpy(adapter->name, ids[i].if_name,string_len);
adapter->name[string_len] = '\0';
strncpy(adapter->desc, ids[i].if_name,string_len);
adapter->desc[string_len] = '\0';
strncpy(adapter->name, ids[i].if_name, EC_MAXLEN_ADAPTERNAME);
adapter->name[EC_MAXLEN_ADAPTERNAME-1] = '\0';
strncpy(adapter->desc, ids[i].if_name, EC_MAXLEN_ADAPTERNAME);
adapter->desc[EC_MAXLEN_ADAPTERNAME-1] = '\0';
}
else
{

View File

@ -201,10 +201,10 @@ void ec_setupheader(void *p)
* @param[in] port = port context struct
* @return new index.
*/
int ecx_getindex(ecx_portt *port)
uint8 ecx_getindex(ecx_portt *port)
{
int idx;
int cnt;
uint8 idx;
uint8 cnt;
pthread_mutex_lock(&(port->getindex_mutex));
@ -240,7 +240,7 @@ int ecx_getindex(ecx_portt *port)
* @param[in] idx = index in buffer array
* @param[in] bufstat = status to set
*/
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat)
{
port->rxbufstat[idx] = bufstat;
if (port->redstate != ECT_RED_NONE)
@ -253,7 +253,7 @@ void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
* @param[in] stacknumber = 0=Primary 1=Secondary stack
* @return socket send result
*/
int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
int ecx_outframe(ecx_portt *port, uint8 idx, int stacknumber)
{
int lp, rval;
ec_stackT *stack;
@ -282,7 +282,7 @@ int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
* @param[in] idx = index in tx buffer array
* @return socket send result
*/
int ecx_outframe_red(ecx_portt *port, int idx)
int ecx_outframe_red(ecx_portt *port, uint8 idx)
{
ec_comt *datagramP;
ec_etherheadert *ehp;
@ -371,11 +371,11 @@ static int ecx_recvpkt(ecx_portt *port, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME or EC_OTHERFRAME.
*/
int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
int ecx_inframe(ecx_portt *port, uint8 idx, int stacknumber)
{
uint16 l;
int rval;
int idxf;
uint8 idxf;
ec_etherheadert *ehp;
ec_comt *ecp;
ec_stackT *stack;
@ -440,7 +440,6 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
}
else
{
assert(0);
/* strange things happened */
}
}
@ -466,7 +465,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
static int ecx_waitinframe_red(ecx_portt *port, uint8 idx, osal_timert *timer)
{
osal_timert timer2;
int wkc = EC_NOFRAME;
@ -549,7 +548,7 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout)
{
int wkc;
osal_timert timer;
@ -572,7 +571,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
* @param[in] timeout = timeout in us
* @return Workcounter or EC_NOFRAME
*/
int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
int ecx_srconfirm(ecx_portt *port, uint8 idx, int timeout)
{
int wkc = EC_NOFRAME;
osal_timert timer1, timer2;
@ -612,37 +611,37 @@ int ec_closenic(void)
return ecx_closenic(&ecx_port);
}
int ec_getindex(void)
uint8 ec_getindex(void)
{
return ecx_getindex(&ecx_port);
}
void ec_setbufstat(int idx, int bufstat)
void ec_setbufstat(uint8 idx, int bufstat)
{
ecx_setbufstat(&ecx_port, idx, bufstat);
}
int ec_outframe(int idx, int stacknumber)
int ec_outframe(uint8 idx, int stacknumber)
{
return ecx_outframe(&ecx_port, idx, stacknumber);
}
int ec_outframe_red(int idx)
int ec_outframe_red(uint8 idx)
{
return ecx_outframe_red(&ecx_port, idx);
}
int ec_inframe(int idx, int stacknumber)
int ec_inframe(uint8 idx, int stacknumber)
{
return ecx_inframe(&ecx_port, idx, stacknumber);
}
int ec_waitinframe(int idx, int timeout)
int ec_waitinframe(uint8 idx, int timeout)
{
return ecx_waitinframe(&ecx_port, idx, timeout);
}
int ec_srconfirm(int idx, int timeout)
int ec_srconfirm(uint8 idx, int timeout)
{
return ecx_srconfirm(&ecx_port, idx, timeout);
}

View File

@ -76,7 +76,7 @@ typedef struct
/** temporary tx buffer length */
int txbuflength2;
/** last used frame index */
int lastidx;
uint8 lastidx;
/** current redundancy state */
int redstate;
/** pointer to redundancy port and buffers */
@ -95,23 +95,23 @@ extern ecx_redportt ecx_redport;
int ec_setupnic(const char * ifname, int secondary);
int ec_closenic(void);
void ec_setbufstat(int idx, int bufstat);
int ec_getindex(void);
int ec_outframe(int idx, int sock);
int ec_outframe_red(int idx);
int ec_waitinframe(int idx, int timeout);
int ec_srconfirm(int idx,int timeout);
void ec_setbufstat(uint8 idx, int bufstat);
uint8 ec_getindex(void);
int ec_outframe(uint8 idx, int sock);
int ec_outframe_red(uint8 idx);
int ec_waitinframe(uint8 idx, int timeout);
int ec_srconfirm(uint8 idx,int timeout);
#endif
void ec_setupheader(void *p);
int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary);
int ecx_closenic(ecx_portt *port);
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat);
int ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, int idx, int sock);
int ecx_outframe_red(ecx_portt *port, int idx);
int ecx_waitinframe(ecx_portt *port, int idx, int timeout);
int ecx_srconfirm(ecx_portt *port, int idx,int timeout);
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat);
uint8 ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, uint8 idx, int sock);
int ecx_outframe_red(ecx_portt *port, uint8 idx);
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout);
int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout);
#ifdef __cplusplus
}

View File

@ -42,7 +42,6 @@ uint16 oshw_ntohs(uint16 network)
ec_adaptert * oshw_find_adapters(void)
{
int i;
int string_len;
struct if_nameindex *ids;
ec_adaptert * adapter;
ec_adaptert * prev_adapter;
@ -70,20 +69,15 @@ ec_adaptert * oshw_find_adapters(void)
ret_adapter = adapter;
}
/* fetch description and name, in Linux we use the same on both */
/* fetch description and name, in macosx we use the same on both */
adapter->next = NULL;
if (ids[i].if_name)
{
string_len = strlen(ids[i].if_name);
if (string_len > (EC_MAXLEN_ADAPTERNAME - 1))
{
string_len = EC_MAXLEN_ADAPTERNAME - 1;
}
strncpy(adapter->name, ids[i].if_name,string_len);
adapter->name[string_len] = '\0';
strncpy(adapter->desc, ids[i].if_name,string_len);
adapter->desc[string_len] = '\0';
strncpy(adapter->name, ids[i].if_name, EC_MAXLEN_ADAPTERNAME);
adapter->name[EC_MAXLEN_ADAPTERNAME-1] = '\0';
strncpy(adapter->desc, ids[i].if_name, EC_MAXLEN_ADAPTERNAME);
adapter->desc[EC_MAXLEN_ADAPTERNAME-1] = '\0';
}
else
{

View File

@ -260,10 +260,10 @@ void ec_setupheader(void *p)
* @param[in] port = port context struct
* @return new index.
*/
int ecx_getindex(ecx_portt *port)
uint8 ecx_getindex(ecx_portt *port)
{
int idx;
int cnt;
uint8 idx;
uint8 cnt;
pthread_mutex_lock( &(port->getindex_mutex) );
@ -299,7 +299,7 @@ int ecx_getindex(ecx_portt *port)
* @param[in] idx = index in buffer array
* @param[in] bufstat = status to set
*/
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat)
{
port->rxbufstat[idx] = bufstat;
if (port->redstate != ECT_RED_NONE)
@ -312,7 +312,7 @@ void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
* @param[in] stacknumber = 0=Primary 1=Secondary stack
* @return socket send result
*/
int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
int ecx_outframe(ecx_portt *port, uint8 idx, int stacknumber)
{
int lp, rval;
ec_stackT *stack;
@ -342,7 +342,7 @@ int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
* @param[in] idx = index in tx buffer array
* @return socket send result
*/
int ecx_outframe_red(ecx_portt *port, int idx)
int ecx_outframe_red(ecx_portt *port, uint8 idx)
{
ec_comt *datagramP;
ec_etherheadert *ehp;
@ -418,11 +418,11 @@ static int ecx_recvpkt(ecx_portt *port, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME or EC_OTHERFRAME.
*/
int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
int ecx_inframe(ecx_portt *port, uint8 idx, int stacknumber)
{
uint16 l;
int rval;
int idxf;
uint8 idxf;
ec_etherheadert *ehp;
ec_comt *ecp;
ec_stackT *stack;
@ -515,7 +515,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
static int ecx_waitinframe_red(ecx_portt *port, uint8 idx, osal_timert *timer)
{
osal_timert timer2;
int wkc = EC_NOFRAME;
@ -598,7 +598,7 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout)
{
int wkc;
osal_timert timer;
@ -621,7 +621,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
* @param[in] timeout = timeout in us
* @return Workcounter or EC_NOFRAME
*/
int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
int ecx_srconfirm(ecx_portt *port, uint8 idx, int timeout)
{
int wkc = EC_NOFRAME;
osal_timert timer1, timer2;
@ -659,37 +659,37 @@ int ec_closenic(void)
return ecx_closenic(&ecx_port);
}
int ec_getindex(void)
uint8 ec_getindex(void)
{
return ecx_getindex(&ecx_port);
}
void ec_setbufstat(int idx, int bufstat)
void ec_setbufstat(uint8 idx, int bufstat)
{
ecx_setbufstat(&ecx_port, idx, bufstat);
}
int ec_outframe(int idx, int stacknumber)
int ec_outframe(uint8 idx, int stacknumber)
{
return ecx_outframe(&ecx_port, idx, stacknumber);
}
int ec_outframe_red(int idx)
int ec_outframe_red(uint8 idx)
{
return ecx_outframe_red(&ecx_port, idx);
}
int ec_inframe(int idx, int stacknumber)
int ec_inframe(uint8 idx, int stacknumber)
{
return ecx_inframe(&ecx_port, idx, stacknumber);
}
int ec_waitinframe(int idx, int timeout)
int ec_waitinframe(uint8 idx, int timeout)
{
return ecx_waitinframe(&ecx_port, idx, timeout);
}
int ec_srconfirm(int idx, int timeout)
int ec_srconfirm(uint8 idx, int timeout)
{
return ecx_srconfirm(&ecx_port, idx, timeout);
}

View File

@ -76,7 +76,7 @@ typedef struct
/** temporary tx buffer length */
int txbuflength2;
/** last used frame index */
int lastidx;
uint8 lastidx;
/** current redundancy state */
int redstate;
/** pointer to redundancy port and buffers */
@ -95,23 +95,23 @@ extern ecx_redportt ecx_redport;
int ec_setupnic(const char * ifname, int secondary);
int ec_closenic(void);
void ec_setbufstat(int idx, int bufstat);
int ec_getindex(void);
int ec_outframe(int idx, int sock);
int ec_outframe_red(int idx);
int ec_waitinframe(int idx, int timeout);
int ec_srconfirm(int idx,int timeout);
void ec_setbufstat(uint8 idx, int bufstat);
uint8 ec_getindex(void);
int ec_outframe(uint8 idx, int sock);
int ec_outframe_red(uint8 idx);
int ec_waitinframe(uint8 idx, int timeout);
int ec_srconfirm(uint8 idx,int timeout);
#endif
void ec_setupheader(void *p);
int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary);
int ecx_closenic(ecx_portt *port);
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat);
int ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, int idx, int sock);
int ecx_outframe_red(ecx_portt *port, int idx);
int ecx_waitinframe(ecx_portt *port, int idx, int timeout);
int ecx_srconfirm(ecx_portt *port, int idx,int timeout);
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat);
uint8 ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, uint8 idx, int sock);
int ecx_outframe_red(ecx_portt *port, uint8 idx);
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout);
int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout);
#ifdef __cplusplus
}

View File

@ -42,7 +42,6 @@ uint16 oshw_ntohs(uint16 network)
ec_adaptert * oshw_find_adapters(void)
{
int i;
int string_len;
struct if_nameindex *ids;
ec_adaptert * adapter;
ec_adaptert * prev_adapter;
@ -70,20 +69,15 @@ ec_adaptert * oshw_find_adapters(void)
ret_adapter = adapter;
}
/* fetch description and name, in Linux we use the same on both */
/* fetch description and name, in rtems we use the same on both */
adapter->next = NULL;
if (ids[i].if_name)
{
string_len = strlen(ids[i].if_name);
if (string_len > (EC_MAXLEN_ADAPTERNAME - 1))
{
string_len = EC_MAXLEN_ADAPTERNAME - 1;
}
strncpy(adapter->name, ids[i].if_name,string_len);
adapter->name[string_len] = '\0';
strncpy(adapter->desc, ids[i].if_name,string_len);
adapter->desc[string_len] = '\0';
strncpy(adapter->name, ids[i].if_name, EC_MAXLEN_ADAPTERNAME);
adapter->name[EC_MAXLEN_ADAPTERNAME-1] = '\0';
strncpy(adapter->desc, ids[i].if_name, EC_MAXLEN_ADAPTERNAME);
adapter->desc[EC_MAXLEN_ADAPTERNAME-1] = '\0';
}
else
{

View File

@ -192,10 +192,10 @@ void ec_setupheader(void *p)
* @param[in] port = port context struct
* @return new index.
*/
int ecx_getindex(ecx_portt *port)
uint8 ecx_getindex(ecx_portt *port)
{
int idx;
int cnt;
uint8 idx;
uint8 cnt;
mtx_lock (port->getindex_mutex);
@ -233,7 +233,7 @@ int ecx_getindex(ecx_portt *port)
* @param[in] idx = index in buffer array
* @param[in] bufstat = status to set
*/
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat)
{
port->rxbufstat[idx] = bufstat;
if (port->redstate != ECT_RED_NONE)
@ -248,7 +248,7 @@ void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
* @param[in] stacknumber = 0=Primary 1=Secondary stack
* @return socket send result
*/
int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
int ecx_outframe(ecx_portt *port, uint8 idx, int stacknumber)
{
int lp, rval;
ec_stackT *stack;
@ -273,7 +273,7 @@ int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
* @param[in] idx = index in tx buffer array
* @return socket send result
*/
int ecx_outframe_red(ecx_portt *port, int idx)
int ecx_outframe_red(ecx_portt *port, uint8 idx)
{
ec_comt *datagramP;
ec_etherheadert *ehp;
@ -347,7 +347,7 @@ static int ecx_recvpkt(ecx_portt *port, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME or EC_OTHERFRAME.
*/
int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
int ecx_inframe(ecx_portt *port, uint8 idx, int stacknumber)
{
uint16 l;
int rval;
@ -441,7 +441,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert timer)
static int ecx_waitinframe_red(ecx_portt *port, uint8 idx, osal_timert timer)
{
int wkc = EC_NOFRAME;
int wkc2 = EC_NOFRAME;
@ -534,7 +534,7 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert timer)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout)
{
int wkc;
osal_timert timer;
@ -557,7 +557,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
* @param[in] timeout = timeout in us
* @return Workcounter or EC_NOFRAME
*/
int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
int ecx_srconfirm(ecx_portt *port, uint8 idx, int timeout)
{
int wkc = EC_NOFRAME;
osal_timert timer;
@ -590,37 +590,37 @@ int ec_closenic(void)
return ecx_closenic(&ecx_port);
}
int ec_getindex(void)
uint8 ec_getindex(void)
{
return ecx_getindex(&ecx_port);
}
void ec_setbufstat(int idx, int bufstat)
void ec_setbufstat(uint8 idx, int bufstat)
{
ecx_setbufstat(&ecx_port, idx, bufstat);
}
int ec_outframe(int idx, int stacknumber)
int ec_outframe(uint8 idx, int stacknumber)
{
return ecx_outframe(&ecx_port, idx, stacknumber);
}
int ec_outframe_red(int idx)
int ec_outframe_red(uint8 idx)
{
return ecx_outframe_red(&ecx_port, idx);
}
int ec_inframe(int idx, int stacknumber)
int ec_inframe(uint8 idx, int stacknumber)
{
return ecx_inframe(&ecx_port, idx, stacknumber);
}
int ec_waitinframe(int idx, int timeout)
int ec_waitinframe(uint8 idx, int timeout)
{
return ecx_waitinframe(&ecx_port, idx, timeout);
}
int ec_srconfirm(int idx, int timeout)
int ec_srconfirm(uint8 idx, int timeout)
{
return ecx_srconfirm(&ecx_port, idx, timeout);
}

View File

@ -69,7 +69,7 @@ typedef struct
/** temporary tx buffer length */
int txbuflength2;
/** last used frame index */
int lastidx;
uint8 lastidx;
/** current redundancy state */
int redstate;
/** pointer to redundancy port and buffers */
@ -88,22 +88,22 @@ extern ecx_redportt ecx_redport;
int ec_setupnic(const char * ifname, int secondary);
int ec_closenic(void);
void ec_setbufstat(int idx, int bufstat);
int ec_getindex(void);
int ec_outframe(int idx, int stacknumber);
int ec_outframe_red(int idx);
int ec_waitinframe(int idx, int timeout);
int ec_srconfirm(int idx,int timeout);
void ec_setbufstat(uint8 idx, int bufstat);
uint8 ec_getindex(void);
int ec_outframe(uint8 idx, int stacknumber);
int ec_outframe_red(uint8 idx);
int ec_waitinframe(uint8 idx, int timeout);
int ec_srconfirm(uint8 idx,int timeout);
#endif
void ec_setupheader(void *p);
int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary);
int ecx_closenic(ecx_portt *port);
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat);
int ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, int idx, int stacknumber);
int ecx_outframe_red(ecx_portt *port, int idx);
int ecx_waitinframe(ecx_portt *port, int idx, int timeout);
int ecx_srconfirm(ecx_portt *port, int idx,int timeout);
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat);
uint8 ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, uint8 idx, int stacknumber);
int ecx_outframe_red(ecx_portt *port, uint8 idx);
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout);
int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout);
#endif

View File

@ -371,10 +371,10 @@ void ec_setupheader(void *p)
* @param[in] port = port context struct
* @return new index.
*/
int ecx_getindex(ecx_portt *port)
uint8 ecx_getindex(ecx_portt *port)
{
int idx;
int cnt;
uint8 idx;
uint8 cnt;
semTake(port->sem_get_index, WAIT_FOREVER);
@ -408,7 +408,7 @@ int ecx_getindex(ecx_portt *port)
* @param[in] idx = index in buffer array
* @param[in] bufstat = status to set
*/
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat)
{
port->rxbufstat[idx] = bufstat;
if (port->redstate != ECT_RED_NONE)
@ -423,7 +423,7 @@ void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
* @param[in] len = bytes to send
* @return driver send result
*/
static int ec_outfram_send(ETHERCAT_PKT_DEV * pPktDev, int idx, void * buf, int len)
static int ec_outfram_send(ETHERCAT_PKT_DEV * pPktDev, uint8 idx, void * buf, int len)
{
STATUS status = OK;
M_BLK_ID pPacket = NULL;
@ -500,7 +500,7 @@ static int ec_outfram_send(ETHERCAT_PKT_DEV * pPktDev, int idx, void * buf, int
* @param[in] stacknumber = 0=Primary 1=Secondary stack
* @return socket send result
*/
int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
int ecx_outframe(ecx_portt *port, uint8 idx, int stacknumber)
{
int rval = 0;
ec_stackT *stack;
@ -537,7 +537,7 @@ int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
* @param[in] idx = index in tx buffer array
* @return socket send result
*/
int ecx_outframe_red(ecx_portt *port, int idx)
int ecx_outframe_red(ecx_portt *port, uint8 idx)
{
ec_comt *datagramP;
ec_etherheadert *ehp;
@ -581,7 +581,7 @@ int ecx_outframe_red(ecx_portt *port, int idx)
static int mux_rx_callback(void* pCookie, long type, M_BLK_ID pMblk, LL_HDR_INFO *llHdrInfo, void *muxUserArg)
{
BOOL ret = FALSE;
int idxf;
uint8 idxf;
ec_comt *ecp;
ec_bufT * tempbuf;
ecx_portt * port;
@ -678,7 +678,7 @@ static int mux_rx_callback(void* pCookie, long type, M_BLK_ID pMblk, LL_HDR_INFO
* @param[in] timeout = timeout in us
* @return >0 if frame is available and read
*/
static int ecx_recvpkt(ecx_portt *port, int idx, int stacknumber, M_BLK_ID * pMblk, int timeout)
static int ecx_recvpkt(ecx_portt *port, uint8 idx, int stacknumber, M_BLK_ID * pMblk, int timeout)
{
int bytesrx = 0;
MSG_Q_ID msgQId;
@ -728,7 +728,7 @@ static int ecx_recvpkt(ecx_portt *port, int idx, int stacknumber, M_BLK_ID * pMb
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME or EC_OTHERFRAME.
*/
int ecx_inframe(ecx_portt *port, int idx, int stacknumber, int timeout)
int ecx_inframe(ecx_portt *port, uint8 idx, int stacknumber, int timeout)
{
uint16 l;
int rval;
@ -792,7 +792,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber, int timeout)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer, int timeout)
static int ecx_waitinframe_red(ecx_portt *port, uint8 idx, osal_timert *timer, int timeout)
{
osal_timert timer2;
int wkc = EC_NOFRAME;
@ -881,7 +881,7 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer, int
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout)
{
int wkc;
osal_timert timer;
@ -904,7 +904,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
* @param[in] timeout = timeout in us
* @return Workcounter or EC_NOFRAME
*/
int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
int ecx_srconfirm(ecx_portt *port, uint8 idx, int timeout)
{
int wkc = EC_NOFRAME;
osal_timert timer1, timer2;
@ -943,37 +943,37 @@ int ec_closenic(void)
return ecx_closenic(&ecx_port);
}
int ec_getindex(void)
uint8 ec_getindex(void)
{
return ecx_getindex(&ecx_port);
}
void ec_setbufstat(int idx, int bufstat)
void ec_setbufstat(uint8 idx, int bufstat)
{
ecx_setbufstat(&ecx_port, idx, bufstat);
}
int ec_outframe(int idx, int stacknumber)
int ec_outframe(uint8 idx, int stacknumber)
{
return ecx_outframe(&ecx_port, idx, stacknumber);
}
int ec_outframe_red(int idx)
int ec_outframe_red(uint8 idx)
{
return ecx_outframe_red(&ecx_port, idx);
}
int ec_inframe(int idx, int stacknumber, int timeout)
int ec_inframe(uint8 idx, int stacknumber, int timeout)
{
return ecx_inframe(&ecx_port, idx, stacknumber, timeout);
}
int ec_waitinframe(int idx, int timeout)
int ec_waitinframe(uint8 idx, int timeout)
{
return ecx_waitinframe(&ecx_port, idx, timeout);
}
int ec_srconfirm(int idx, int timeout)
int ec_srconfirm(uint8 idx, int timeout)
{
return ecx_srconfirm(&ecx_port, idx, timeout);
}

View File

@ -85,7 +85,7 @@ typedef struct ecx_port
/** temporary tx buffer length */
int txbuflength2;
/** last used frame index */
int lastidx;
uint8 lastidx;
/** current redundancy state */
int redstate;
/** pointer to redundancy port and buffers */
@ -105,23 +105,23 @@ extern ecx_redportt ecx_redport;
int ec_setupnic(const char * ifname, int secondary);
int ec_closenic(void);
void ec_setbufstat(int idx, int bufstat);
int ec_getindex(void);
int ec_outframe(int idx, int sock);
int ec_outframe_red(int idx);
int ec_waitinframe(int idx, int timeout);
int ec_srconfirm(int idx,int timeout);
void ec_setbufstat(uint8 idx, int bufstat);
uint8 ec_getindex(void);
int ec_outframe(uint8 idx, int sock);
int ec_outframe_red(uint8 idx);
int ec_waitinframe(uint8 idx, int timeout);
int ec_srconfirm(uint8 idx,int timeout);
#endif
void ec_setupheader(void *p);
int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary);
int ecx_closenic(ecx_portt *port);
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat);
int ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, int idx, int sock);
int ecx_outframe_red(ecx_portt *port, int idx);
int ecx_waitinframe(ecx_portt *port, int idx, int timeout);
int ecx_srconfirm(ecx_portt *port, int idx,int timeout);
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat);
uint8 ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, uint8 idx, int sock);
int ecx_outframe_red(ecx_portt *port, uint8 idx);
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout);
int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout);
#ifdef __cplusplus
}

View File

@ -202,10 +202,10 @@ void ec_setupheader(void *p)
* @param[in] port = port context struct
* @return new index.
*/
int ecx_getindex(ecx_portt *port)
uint8 ecx_getindex(ecx_portt *port)
{
int idx;
int cnt;
uint8 idx;
uint8 cnt;
EnterCriticalSection(&(port->getindex_mutex));
@ -241,7 +241,7 @@ int ecx_getindex(ecx_portt *port)
* @param[in] idx = index in buffer array
* @param[in] bufstat = status to set
*/
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat)
{
port->rxbufstat[idx] = bufstat;
if (port->redstate != ECT_RED_NONE)
@ -254,7 +254,7 @@ void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
* @param[in] stacknumber = 0=Primary 1=Secondary stack
* @return socket send result
*/
int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
int ecx_outframe(ecx_portt *port, uint8 idx, int stacknumber)
{
int lp, rval;
ec_stackT *stack;
@ -283,7 +283,7 @@ int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
* @param[in] idx = index in tx buffer array
* @return socket send result
*/
int ecx_outframe_red(ecx_portt *port, int idx)
int ecx_outframe_red(ecx_portt *port, uint8 idx)
{
ec_comt *datagramP;
ec_etherheadert *ehp;
@ -371,11 +371,11 @@ static int ecx_recvpkt(ecx_portt *port, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME or EC_OTHERFRAME.
*/
int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
int ecx_inframe(ecx_portt *port, uint8 idx, int stacknumber)
{
uint16 l;
int rval;
int idxf;
uint8 idxf;
ec_etherheadert *ehp;
ec_comt *ecp;
ec_stackT *stack;
@ -465,7 +465,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
static int ecx_waitinframe_red(ecx_portt *port, uint8 idx, osal_timert *timer)
{
osal_timert timer2;
int wkc = EC_NOFRAME;
@ -548,7 +548,7 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
* @return Workcounter if a frame is found with corresponding index, otherwise
* EC_NOFRAME.
*/
int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout)
{
int wkc;
osal_timert timer;
@ -571,7 +571,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
* @param[in] timeout = timeout in us
* @return Workcounter or EC_NOFRAME
*/
int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
int ecx_srconfirm(ecx_portt *port, uint8 idx, int timeout)
{
int wkc = EC_NOFRAME;
osal_timert timer1, timer2;
@ -611,37 +611,37 @@ int ec_closenic(void)
return ecx_closenic(&ecx_port);
}
int ec_getindex(void)
uint8 ec_getindex(void)
{
return ecx_getindex(&ecx_port);
}
void ec_setbufstat(int idx, int bufstat)
void ec_setbufstat(uint8 idx, int bufstat)
{
ecx_setbufstat(&ecx_port, idx, bufstat);
}
int ec_outframe(int idx, int stacknumber)
int ec_outframe(uint8 idx, int stacknumber)
{
return ecx_outframe(&ecx_port, idx, stacknumber);
}
int ec_outframe_red(int idx)
int ec_outframe_red(uint8 idx)
{
return ecx_outframe_red(&ecx_port, idx);
}
int ec_inframe(int idx, int stacknumber)
int ec_inframe(uint8 idx, int stacknumber)
{
return ecx_inframe(&ecx_port, idx, stacknumber);
}
int ec_waitinframe(int idx, int timeout)
int ec_waitinframe(uint8 idx, int timeout)
{
return ecx_waitinframe(&ecx_port, idx, timeout);
}
int ec_srconfirm(int idx, int timeout)
int ec_srconfirm(uint8 idx, int timeout)
{
return ecx_srconfirm(&ecx_port, idx, timeout);
}

View File

@ -79,7 +79,7 @@ typedef struct
/** temporary tx buffer length */
int txbuflength2;
/** last used frame index */
int lastidx;
uint8 lastidx;
/** current redundancy state */
int redstate;
/** pointer to redundancy port and buffers */
@ -98,23 +98,23 @@ extern ecx_redportt ecx_redport;
int ec_setupnic(const char * ifname, int secondary);
int ec_closenic(void);
void ec_setbufstat(int idx, int bufstat);
int ec_getindex(void);
int ec_outframe(int idx, int sock);
int ec_outframe_red(int idx);
int ec_waitinframe(int idx, int timeout);
int ec_srconfirm(int idx,int timeout);
void ec_setbufstat(uint8 idx, int bufstat);
uint8 ec_getindex(void);
int ec_outframe(uint8 idx, int sock);
int ec_outframe_red(uint8 idx);
int ec_waitinframe(uint8 idx, int timeout);
int ec_srconfirm(uint8 idx,int timeout);
#endif
void ec_setupheader(void *p);
int ecx_setupnic(ecx_portt *port, const char * ifname, int secondary);
int ecx_closenic(ecx_portt *port);
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat);
int ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, int idx, int sock);
int ecx_outframe_red(ecx_portt *port, int idx);
int ecx_waitinframe(ecx_portt *port, int idx, int timeout);
int ecx_srconfirm(ecx_portt *port, int idx,int timeout);
void ecx_setbufstat(ecx_portt *port, uint8 idx, int bufstat);
uint8 ecx_getindex(ecx_portt *port);
int ecx_outframe(ecx_portt *port, uint8 idx, int sock);
int ecx_outframe_red(ecx_portt *port, uint8 idx);
int ecx_waitinframe(ecx_portt *port, uint8 idx, int timeout);
int ecx_srconfirm(ecx_portt *port, uint8 idx,int timeout);
#ifdef __cplusplus
}

View File

@ -42,7 +42,6 @@ ec_adaptert * oshw_find_adapters (void)
ec_adaptert * prev_adapter;
ec_adaptert * ret_adapter = NULL;
char errbuf[PCAP_ERRBUF_SIZE];
size_t string_len;
/* find all devices */
if (pcap_findalldevs(&alldevs, errbuf) == -1)
@ -73,13 +72,8 @@ ec_adaptert * oshw_find_adapters (void)
adapter->next = NULL;
if (d->name)
{
string_len = strlen(d->name);
if (string_len > (EC_MAXLEN_ADAPTERNAME - 1))
{
string_len = EC_MAXLEN_ADAPTERNAME - 1;
}
strncpy(adapter->name, d->name,string_len);
adapter->name[string_len] = '\0';
strncpy(adapter->name, d->name, EC_MAXLEN_ADAPTERNAME);
adapter->name[EC_MAXLEN_ADAPTERNAME-1] = '\0';
}
else
{
@ -87,13 +81,8 @@ ec_adaptert * oshw_find_adapters (void)
}
if (d->description)
{
string_len = strlen(d->description);
if (string_len > (EC_MAXLEN_ADAPTERNAME - 1))
{
string_len = EC_MAXLEN_ADAPTERNAME - 1;
}
strncpy(adapter->desc, d->description,string_len);
adapter->desc[string_len] = '\0';
strncpy(adapter->desc, d->description, EC_MAXLEN_ADAPTERNAME);
adapter->desc[EC_MAXLEN_ADAPTERNAME-1] = '\0';
}
else
{

View File

@ -103,7 +103,7 @@ int ecx_setupdatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, uint16
* @param[in] data = databuffer to be copied in datagram
* @return Offset to data in rx frame, usefull to retrieve data after RX.
*/
int ecx_adddatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data)
uint16 ecx_adddatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data)
{
ec_comt *datagramP;
uint8 *frameP;
@ -111,7 +111,7 @@ int ecx_adddatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, boolean
frameP = frame;
/* copy previous frame size */
prevlength = port->txbuflength[idx];
prevlength = (uint16)port->txbuflength[idx];
datagramP = (ec_comt*)&frameP[ETH_HEADERSIZE];
/* add new datagram to ethernet frame size */
datagramP->elength = htoes( etohs(datagramP->elength) + EC_HEADERSIZE + length );
@ -541,7 +541,7 @@ int ec_setupdatagram(void *frame, uint8 com, uint8 idx, uint16 ADP, uint16 ADO,
return ecx_setupdatagram (&ecx_port, frame, com, idx, ADP, ADO, length, data);
}
int ec_adddatagram (void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data)
uint16 ec_adddatagram (void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data)
{
return ecx_adddatagram (&ecx_port, frame, com, idx, more, ADP, ADO, length, data);
}

View File

@ -17,7 +17,7 @@ extern "C"
#endif
int ecx_setupdatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, uint16 ADP, uint16 ADO, uint16 length, void *data);
int ecx_adddatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data);
uint16 ecx_adddatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data);
int ecx_BWR(ecx_portt *port, uint16 ADP,uint16 ADO,uint16 length,void *data,int timeout);
int ecx_BRD(ecx_portt *port, uint16 ADP,uint16 ADO,uint16 length,void *data,int timeout);
int ecx_APRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout);
@ -37,7 +37,7 @@ int ecx_LRWDC(ecx_portt *port, uint32 LogAdr, uint16 length, void *data, uint16
#ifdef EC_VER1
int ec_setupdatagram(void *frame, uint8 com, uint8 idx, uint16 ADP, uint16 ADO, uint16 length, void *data);
int ec_adddatagram(void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data);
uint16 ec_adddatagram(void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data);
int ec_BWR(uint16 ADP,uint16 ADO,uint16 length,void *data,int timeout);
int ec_BRD(uint16 ADP,uint16 ADO,uint16 length,void *data,int timeout);
int ec_APRD(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout);

View File

@ -142,7 +142,7 @@ int ecx_SDOread(ecx_contextt *context, uint16 slave, uint16 index, uint8 subinde
/* get new mailbox count value, used as session handle */
cnt = ec_nextmbxcnt(context->slavelist[slave].mbx_cnt);
context->slavelist[slave].mbx_cnt = cnt;
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + (cnt << 4); /* CoE */
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + MBX_HDR_SET_CNT(cnt); /* CoE */
SDOp->CANOpen = htoes(0x000 + (ECT_COES_SDOREQ << 12)); /* number 9bits service upper 4 bits (SDO request) */
if (CA)
{
@ -218,7 +218,7 @@ int ecx_SDOread(ecx_contextt *context, uint16 slave, uint16 index, uint8 subinde
SDOp->MbxHeader.priority = 0x00;
cnt = ec_nextmbxcnt(context->slavelist[slave].mbx_cnt);
context->slavelist[slave].mbx_cnt = cnt;
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + (cnt << 4); /* CoE */
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + MBX_HDR_SET_CNT(cnt); /* CoE */
SDOp->CANOpen = htoes(0x000 + (ECT_COES_SDOREQ << 12)); /* number 9bits service upper 4 bits (SDO request) */
SDOp->Command = ECT_SDO_SEG_UP_REQ + toggle; /* segment upload request */
SDOp->Index = htoes(index);
@ -331,10 +331,9 @@ int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubInd
boolean CA, int psize, void *p, int Timeout)
{
ec_SDOt *SDOp, *aSDOp;
int wkc, maxdata;
int wkc, maxdata, framedatasize;
ec_mbxbuft MbxIn, MbxOut;
uint8 cnt, toggle;
uint16 framedatasize;
boolean NotLast;
uint8 *hp;
@ -354,7 +353,7 @@ int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubInd
/* get new mailbox counter, used for session handle */
cnt = ec_nextmbxcnt(context->slavelist[Slave].mbx_cnt);
context->slavelist[Slave].mbx_cnt = cnt;
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + (cnt << 4); /* CoE */
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + MBX_HDR_SET_CNT(cnt); /* CoE */
SDOp->CANOpen = htoes(0x000 + (ECT_COES_SDOREQ << 12)); /* number 9bits service upper 4 bits */
SDOp->Command = ECT_SDO_DOWN_EXP | (((4 - psize) << 2) & 0x0c); /* expedited SDO download transfer */
SDOp->Index = htoes(Index);
@ -404,13 +403,13 @@ int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubInd
framedatasize = maxdata; /* segmented transfer needed */
NotLast = TRUE;
}
SDOp->MbxHeader.length = htoes(0x0a + framedatasize);
SDOp->MbxHeader.length = htoes((uint16)(0x0a + framedatasize));
SDOp->MbxHeader.address = htoes(0x0000);
SDOp->MbxHeader.priority = 0x00;
/* get new mailbox counter, used for session handle */
cnt = ec_nextmbxcnt(context->slavelist[Slave].mbx_cnt);
context->slavelist[Slave].mbx_cnt = cnt;
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + (cnt << 4); /* CoE */
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + MBX_HDR_SET_CNT(cnt); /* CoE */
SDOp->CANOpen = htoes(0x000 + (ECT_COES_SDOREQ << 12)); /* number 9bits service upper 4 bits */
if (CA)
{
@ -466,18 +465,18 @@ int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubInd
if (!NotLast && (framedatasize < 7))
{
SDOp->MbxHeader.length = htoes(0x0a); /* minimum size */
SDOp->Command = 0x01 + ((7 - framedatasize) << 1); /* last segment reduced octets */
SDOp->Command = (uint8)(0x01 + ((7 - framedatasize) << 1)); /* last segment reduced octets */
}
else
{
SDOp->MbxHeader.length = htoes(framedatasize + 3); /* data + 2 CoE + 1 SDO */
SDOp->MbxHeader.length = htoes((uint16)(framedatasize + 3)); /* data + 2 CoE + 1 SDO */
}
SDOp->MbxHeader.address = htoes(0x0000);
SDOp->MbxHeader.priority = 0x00;
/* get new mailbox counter value */
cnt = ec_nextmbxcnt(context->slavelist[Slave].mbx_cnt);
context->slavelist[Slave].mbx_cnt = cnt;
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + (cnt << 4); /* CoE */
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + MBX_HDR_SET_CNT(cnt); /* CoE */
SDOp->CANOpen = htoes(0x000 + (ECT_COES_SDOREQ << 12)); /* number 9bits service upper 4 bits (SDO request) */
SDOp->Command = SDOp->Command + toggle; /* add toggle bit to command byte */
/* copy parameter data to mailbox */
@ -552,10 +551,9 @@ int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubInd
int ecx_RxPDO(ecx_contextt *context, uint16 Slave, uint16 RxPDOnumber, int psize, void *p)
{
ec_SDOt *SDOp;
int wkc, maxdata;
int wkc, maxdata, framedatasize;
ec_mbxbuft MbxIn, MbxOut;
uint8 cnt;
uint16 framedatasize;
ec_clearmbx(&MbxIn);
/* Empty slave out mailbox if something is in. Timeout set to 0 */
@ -568,13 +566,13 @@ int ecx_RxPDO(ecx_contextt *context, uint16 Slave, uint16 RxPDOnumber, int psize
{
framedatasize = maxdata; /* limit transfer */
}
SDOp->MbxHeader.length = htoes(0x02 + framedatasize);
SDOp->MbxHeader.length = htoes((uint16)(0x02 + framedatasize));
SDOp->MbxHeader.address = htoes(0x0000);
SDOp->MbxHeader.priority = 0x00;
/* get new mailbox counter, used for session handle */
cnt = ec_nextmbxcnt(context->slavelist[Slave].mbx_cnt);
context->slavelist[Slave].mbx_cnt = cnt;
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + (cnt << 4); /* CoE */
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + MBX_HDR_SET_CNT(cnt); /* CoE */
SDOp->CANOpen = htoes((RxPDOnumber & 0x01ff) + (ECT_COES_RXPDO << 12)); /* number 9bits service upper 4 bits */
/* copy PDO data to mailbox */
memcpy(&SDOp->Command, p, framedatasize);
@ -616,7 +614,7 @@ int ecx_TxPDO(ecx_contextt *context, uint16 slave, uint16 TxPDOnumber , int *psi
/* get new mailbox counter, used for session handle */
cnt = ec_nextmbxcnt(context->slavelist[slave].mbx_cnt);
context->slavelist[slave].mbx_cnt = cnt;
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + (cnt << 4); /* CoE */
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + MBX_HDR_SET_CNT(cnt); /* CoE */
SDOp->CANOpen = htoes((TxPDOnumber & 0x01ff) + (ECT_COES_TXPDO_RR << 12)); /* number 9bits service upper 4 bits */
wkc = ecx_mbxsend(context, slave, (ec_mbxbuft *)&MbxOut, EC_TIMEOUTTXM);
if (wkc > 0)
@ -672,12 +670,13 @@ int ecx_TxPDO(ecx_contextt *context, uint16 slave, uint16 TxPDOnumber , int *psi
* @param[in] PDOassign = PDO assign object
* @return total bitlength of PDO assign
*/
int ecx_readPDOassign(ecx_contextt *context, uint16 Slave, uint16 PDOassign)
uint32 ecx_readPDOassign(ecx_contextt *context, uint16 Slave, uint16 PDOassign)
{
uint16 idxloop, nidx, subidxloop, rdat, idx, subidx;
uint8 subcnt;
int wkc, bsize = 0, rdl;
int wkc, rdl;
int32 rdat2;
uint32 bsize = 0;
rdl = sizeof(rdat); rdat = 0;
/* read PDO assign subindex 0 ( = number of PDO's) */
@ -737,11 +736,12 @@ int ecx_readPDOassign(ecx_contextt *context, uint16 Slave, uint16 PDOassign)
* @param[in] PDOassign = PDO assign object
* @return total bitlength of PDO assign
*/
int ecx_readPDOassignCA(ecx_contextt *context, uint16 Slave, int Thread_n,
uint32 ecx_readPDOassignCA(ecx_contextt *context, uint16 Slave, int Thread_n,
uint16 PDOassign)
{
uint16 idxloop, nidx, subidxloop, idx, subidx;
int wkc, bsize = 0, rdl;
int wkc, rdl;
uint32 bsize = 0;
/* find maximum size of PDOassign buffer */
rdl = sizeof(ec_PDOassignt);
@ -807,12 +807,12 @@ int ecx_readPDOassignCA(ecx_contextt *context, uint16 Slave, int Thread_n,
* @param[out] Isize = Size in bits of input mapping (txPDO) found
* @return >0 if mapping successful.
*/
int ecx_readPDOmap(ecx_contextt *context, uint16 Slave, int *Osize, int *Isize)
int ecx_readPDOmap(ecx_contextt *context, uint16 Slave, uint32 *Osize, uint32 *Isize)
{
int wkc, rdl;
int retVal = 0;
uint8 nSM, iSM, tSM;
int Tsize;
uint32 Tsize;
uint8 SMt_bug_add;
*Isize = 0;
@ -868,7 +868,7 @@ int ecx_readPDOmap(ecx_contextt *context, uint16 Slave, int *Osize, int *Isize)
/* if a mapping is found */
if (Tsize)
{
context->slavelist[Slave].SM[iSM].SMlength = htoes((Tsize + 7) / 8);
context->slavelist[Slave].SM[iSM].SMlength = htoes((uint16)((Tsize + 7) / 8));
if (tSM == 3)
{
/* we are doing outputs */
@ -907,12 +907,12 @@ int ecx_readPDOmap(ecx_contextt *context, uint16 Slave, int *Osize, int *Isize)
* @param[out] Isize = Size in bits of input mapping (txPDO) found
* @return >0 if mapping successful.
*/
int ecx_readPDOmapCA(ecx_contextt *context, uint16 Slave, int Thread_n, int *Osize, int *Isize)
int ecx_readPDOmapCA(ecx_contextt *context, uint16 Slave, int Thread_n, uint32 *Osize, uint32 *Isize)
{
int wkc, rdl;
int retVal = 0;
uint8 nSM, iSM, tSM;
int Tsize;
uint32 Tsize;
uint8 SMt_bug_add;
*Isize = 0;
@ -964,7 +964,7 @@ int ecx_readPDOmapCA(ecx_contextt *context, uint16 Slave, int Thread_n, int *Osi
/* if a mapping is found */
if (Tsize)
{
context->slavelist[Slave].SM[iSM].SMlength = htoes((Tsize + 7) / 8);
context->slavelist[Slave].SM[iSM].SMlength = htoes((uint16)((Tsize + 7) / 8));
if (tSM == 3)
{
/* we are doing outputs */
@ -1019,7 +1019,7 @@ int ecx_readODlist(ecx_contextt *context, uint16 Slave, ec_ODlistt *pODlist)
/* Get new mailbox counter value */
cnt = ec_nextmbxcnt(context->slavelist[Slave].mbx_cnt);
context->slavelist[Slave].mbx_cnt = cnt;
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + (cnt << 4); /* CoE */
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + MBX_HDR_SET_CNT(cnt); /* CoE */
SDOp->CANOpen = htoes(0x000 + (ECT_COES_SDOINFO << 12)); /* number 9bits service upper 4 bits */
SDOp->Opcode = ECT_GET_ODLIST_REQ; /* get object description list request */
SDOp->Reserved = 0;
@ -1139,7 +1139,7 @@ int ecx_readODdescription(ecx_contextt *context, uint16 Item, ec_ODlistt *pODlis
/* Get new mailbox counter value */
cnt = ec_nextmbxcnt(context->slavelist[Slave].mbx_cnt);
context->slavelist[Slave].mbx_cnt = cnt;
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + (cnt << 4); /* CoE */
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + MBX_HDR_SET_CNT(cnt); /* CoE */
SDOp->CANOpen = htoes(0x000 + (ECT_COES_SDOINFO << 12)); /* number 9bits service upper 4 bits */
SDOp->Opcode = ECT_GET_OD_REQ; /* get object description request */
SDOp->Reserved = 0;
@ -1224,7 +1224,7 @@ int ecx_readOEsingle(ecx_contextt *context, uint16 Item, uint8 SubI, ec_ODlistt
/* Get new mailbox counter value */
cnt = ec_nextmbxcnt(context->slavelist[Slave].mbx_cnt);
context->slavelist[Slave].mbx_cnt = cnt;
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + (cnt << 4); /* CoE */
SDOp->MbxHeader.mbxtype = ECT_MBXT_COE + MBX_HDR_SET_CNT(cnt); /* CoE */
SDOp->CANOpen = htoes(0x000 + (ECT_COES_SDOINFO << 12)); /* number 9bits service upper 4 bits */
SDOp->Opcode = ECT_GET_OE_REQ; /* get object entry description request */
SDOp->Reserved = 0;
@ -1408,7 +1408,7 @@ int ec_TxPDO(uint16 slave, uint16 TxPDOnumber , int *psize, void *p, int timeout
* @param[in] PDOassign = PDO assign object
* @return total bitlength of PDO assign
*/
int ec_readPDOassign(uint16 Slave, uint16 PDOassign)
uint32 ec_readPDOassign(uint16 Slave, uint16 PDOassign)
{
return ecx_readPDOassign(&ecx_context, Slave, PDOassign);
}
@ -1420,7 +1420,7 @@ int ec_readPDOassign(uint16 Slave, uint16 PDOassign)
* @return total bitlength of PDO assign
* @see ecx_readPDOmap
*/
int ec_readPDOassignCA(uint16 Slave, uint16 PDOassign, int Thread_n)
uint32 ec_readPDOassignCA(uint16 Slave, uint16 PDOassign, int Thread_n)
{
return ecx_readPDOassignCA(&ecx_context, Slave, Thread_n, PDOassign);
}
@ -1438,7 +1438,7 @@ int ec_readPDOassignCA(uint16 Slave, uint16 PDOassign, int Thread_n)
* @param[out] Isize = Size in bits of input mapping (txPDO) found
* @return >0 if mapping succesful.
*/
int ec_readPDOmap(uint16 Slave, int *Osize, int *Isize)
int ec_readPDOmap(uint16 Slave, uint32 *Osize, uint32 *Isize)
{
return ecx_readPDOmap(&ecx_context, Slave, Osize, Isize);
}
@ -1456,7 +1456,7 @@ int ec_readPDOmap(uint16 Slave, int *Osize, int *Isize)
* @return >0 if mapping succesful.
* @see ecx_readPDOmap ec_readPDOmapCA
*/
int ec_readPDOmapCA(uint16 Slave, int Thread_n, int *Osize, int *Isize)
int ec_readPDOmapCA(uint16 Slave, int Thread_n, uint32 *Osize, uint32 *Isize)
{
return ecx_readPDOmapCA(&ecx_context, Slave, Thread_n, Osize, Isize);
}

View File

@ -66,8 +66,8 @@ int ec_SDOwrite(uint16 Slave, uint16 Index, uint8 SubIndex,
boolean CA, int psize, void *p, int Timeout);
int ec_RxPDO(uint16 Slave, uint16 RxPDOnumber , int psize, void *p);
int ec_TxPDO(uint16 slave, uint16 TxPDOnumber , int *psize, void *p, int timeout);
int ec_readPDOmap(uint16 Slave, int *Osize, int *Isize);
int ec_readPDOmapCA(uint16 Slave, int Thread_n, int *Osize, int *Isize);
int ec_readPDOmap(uint16 Slave, uint32 *Osize, uint32 *Isize);
int ec_readPDOmapCA(uint16 Slave, int Thread_n, uint32 *Osize, uint32 *Isize);
int ec_readODlist(uint16 Slave, ec_ODlistt *pODlist);
int ec_readODdescription(uint16 Item, ec_ODlistt *pODlist);
int ec_readOEsingle(uint16 Item, uint8 SubI, ec_ODlistt *pODlist, ec_OElistt *pOElist);
@ -81,8 +81,8 @@ int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubInd
boolean CA, int psize, void *p, int Timeout);
int ecx_RxPDO(ecx_contextt *context, uint16 Slave, uint16 RxPDOnumber , int psize, void *p);
int ecx_TxPDO(ecx_contextt *context, uint16 slave, uint16 TxPDOnumber , int *psize, void *p, int timeout);
int ecx_readPDOmap(ecx_contextt *context, uint16 Slave, int *Osize, int *Isize);
int ecx_readPDOmapCA(ecx_contextt *context, uint16 Slave, int Thread_n, int *Osize, int *Isize);
int ecx_readPDOmap(ecx_contextt *context, uint16 Slave, uint32 *Osize, uint32 *Isize);
int ecx_readPDOmapCA(ecx_contextt *context, uint16 Slave, int Thread_n, uint32 *Osize, uint32 *Isize);
int ecx_readODlist(ecx_contextt *context, uint16 Slave, ec_ODlistt *pODlist);
int ecx_readODdescription(ecx_contextt *context, uint16 Item, ec_ODlistt *pODlist);
int ecx_readOEsingle(ecx_contextt *context, uint16 Item, uint8 SubI, ec_ODlistt *pODlist, ec_OElistt *pOElist);

View File

@ -484,7 +484,7 @@ int ecx_config_init(ecx_contextt *context, uint8 usetable)
context->slavelist[slave].SM[1].SMlength = htoes(context->slavelist[slave].mbx_rl);
context->slavelist[slave].SM[1].SMflags = htoel(EC_DEFAULTMBXSM1);
eedat = ecx_readeeprom2(context, slave, EC_TIMEOUTEEP);
context->slavelist[slave].mbx_proto = etohl(eedat);
context->slavelist[slave].mbx_proto = (uint16)etohl(eedat);
}
cindex = 0;
/* use configuration table ? */
@ -607,7 +607,7 @@ int ecx_config_init(ecx_contextt *context, uint8 usetable)
/* If slave has SII mapping and same slave ID done before, use previous mapping.
* This is safe because SII mapping is constant for same slave ID.
*/
static int ecx_lookup_mapping(ecx_contextt *context, uint16 slave, int *Osize, int *Isize)
static int ecx_lookup_mapping(ecx_contextt *context, uint16 slave, uint32 *Osize, uint32 *Isize)
{
int i, nSM;
if ((slave > 1) && (*(context->slavecount) > 0))
@ -629,8 +629,8 @@ static int ecx_lookup_mapping(ecx_contextt *context, uint16 slave, int *Osize, i
}
*Osize = context->slavelist[i].Obits;
*Isize = context->slavelist[i].Ibits;
context->slavelist[slave].Obits = *Osize;
context->slavelist[slave].Ibits = *Isize;
context->slavelist[slave].Obits = (uint16)*Osize;
context->slavelist[slave].Ibits = (uint16)*Isize;
EC_PRINT("Copy mapping slave %d from %d.\n", slave, i);
return 1;
}
@ -640,7 +640,7 @@ static int ecx_lookup_mapping(ecx_contextt *context, uint16 slave, int *Osize, i
static int ecx_map_coe_soe(ecx_contextt *context, uint16 slave, int thread_n)
{
int Isize, Osize;
uint32 Isize, Osize;
int rval;
ecx_statecheck(context, slave, EC_STATE_PRE_OP, EC_TIMEOUTSTATE); /* check state change pre-op */
@ -675,18 +675,18 @@ static int ecx_map_coe_soe(ecx_contextt *context, uint16 slave, int thread_n)
/* read PDO mapping via CoE */
rval = ecx_readPDOmap(context, slave, &Osize, &Isize);
}
EC_PRINT(" CoE Osize:%d Isize:%d\n", Osize, Isize);
EC_PRINT(" CoE Osize:%u Isize:%u\n", Osize, Isize);
}
if ((!Isize && !Osize) && (context->slavelist[slave].mbx_proto & ECT_MBXPROT_SOE)) /* has SoE */
{
/* read AT / MDT mapping via SoE */
rval = ecx_readIDNmap(context, slave, &Osize, &Isize);
context->slavelist[slave].SM[2].SMlength = htoes((Osize + 7) / 8);
context->slavelist[slave].SM[3].SMlength = htoes((Isize + 7) / 8);
EC_PRINT(" SoE Osize:%d Isize:%d\n", Osize, Isize);
context->slavelist[slave].SM[2].SMlength = htoes((uint16)((Osize + 7) / 8));
context->slavelist[slave].SM[3].SMlength = htoes((uint16)((Isize + 7) / 8));
EC_PRINT(" SoE Osize:%u Isize:%u\n", Osize, Isize);
}
context->slavelist[slave].Obits = Osize;
context->slavelist[slave].Ibits = Isize;
context->slavelist[slave].Obits = (uint16)Osize;
context->slavelist[slave].Ibits = (uint16)Isize;
}
return 1;
@ -694,7 +694,7 @@ static int ecx_map_coe_soe(ecx_contextt *context, uint16 slave, int thread_n)
static int ecx_map_sii(ecx_contextt *context, uint16 slave)
{
int Isize, Osize;
uint32 Isize, Osize;
int nSM;
ec_eepromPDOt eepPDO;
@ -708,8 +708,8 @@ static int ecx_map_sii(ecx_contextt *context, uint16 slave)
if (!Isize && !Osize) /* find PDO mapping by SII */
{
memset(&eepPDO, 0, sizeof(eepPDO));
Isize = (int)ecx_siiPDO(context, slave, &eepPDO, 0);
EC_PRINT(" SII Isize:%d\n", Isize);
Isize = ecx_siiPDO(context, slave, &eepPDO, 0);
EC_PRINT(" SII Isize:%u\n", Isize);
for( nSM=0 ; nSM < EC_MAXSM ; nSM++ )
{
if (eepPDO.SMbitsize[nSM] > 0)
@ -719,8 +719,8 @@ static int ecx_map_sii(ecx_contextt *context, uint16 slave)
EC_PRINT(" SM%d length %d\n", nSM, eepPDO.SMbitsize[nSM]);
}
}
Osize = (int)ecx_siiPDO(context, slave, &eepPDO, 1);
EC_PRINT(" SII Osize:%d\n", Osize);
Osize = ecx_siiPDO(context, slave, &eepPDO, 1);
EC_PRINT(" SII Osize:%u\n", Osize);
for( nSM=0 ; nSM < EC_MAXSM ; nSM++ )
{
if (eepPDO.SMbitsize[nSM] > 0)
@ -731,8 +731,8 @@ static int ecx_map_sii(ecx_contextt *context, uint16 slave)
}
}
}
context->slavelist[slave].Obits = Osize;
context->slavelist[slave].Ibits = Isize;
context->slavelist[slave].Obits = (uint16)Osize;
context->slavelist[slave].Ibits = (uint16)Isize;
EC_PRINT(" ISIZE:%d %d OSIZE:%d\n",
context->slavelist[slave].Ibits, Isize,context->slavelist[slave].Obits);
@ -897,9 +897,10 @@ static void ecx_config_create_input_mappings(ecx_contextt *context, void *pIOmap
uint8 group, int16 slave, uint32 * LogAddr, uint8 * BitPos)
{
int BitCount = 0;
int ByteCount = 0;
int FMMUsize = 0;
int FMMUdone = 0;
int AddToInputsWKC = 0;
uint16 ByteCount = 0;
uint16 FMMUsize = 0;
uint8 SMc = 0;
uint16 EndAddr;
uint16 SMlength;
@ -962,7 +963,7 @@ static void ecx_config_create_input_mappings(ecx_contextt *context, void *pIOmap
*LogAddr += 1;
*BitPos -= 8;
}
FMMUsize = *LogAddr - etohl(context->slavelist[slave].FMMU[FMMUc].LogStart) + 1;
FMMUsize = (uint16)(*LogAddr - etohl(context->slavelist[slave].FMMU[FMMUc].LogStart) + 1);
context->slavelist[slave].FMMU[FMMUc].LogLength = htoes(FMMUsize);
context->slavelist[slave].FMMU[FMMUc].LogEndbit = *BitPos;
*BitPos += 1;
@ -986,7 +987,7 @@ static void ecx_config_create_input_mappings(ecx_contextt *context, void *pIOmap
FMMUsize = ByteCount;
if ((FMMUsize + FMMUdone)> (int)context->slavelist[slave].Ibytes)
{
FMMUsize = context->slavelist[slave].Ibytes - FMMUdone;
FMMUsize = (uint16)(context->slavelist[slave].Ibytes - FMMUdone);
}
*LogAddr += FMMUsize;
context->slavelist[slave].FMMU[FMMUc].LogLength = htoes(FMMUsize);
@ -1002,8 +1003,9 @@ static void ecx_config_create_input_mappings(ecx_contextt *context, void *pIOmap
/* program FMMU for input */
ecx_FPWR(context->port, configadr, ECT_REG_FMMU0 + (sizeof(ec_fmmut) * FMMUc),
sizeof(ec_fmmut), &(context->slavelist[slave].FMMU[FMMUc]), EC_TIMEOUTRET3);
/* add one for an input FMMU */
context->grouplist[group].inputsWKC++;
/* Set flag to add one for an input FMMU,
a single ESC can only contribute once */
AddToInputsWKC = 1;
}
if (!context->slavelist[slave].inputs)
{
@ -1029,15 +1031,20 @@ static void ecx_config_create_input_mappings(ecx_contextt *context, void *pIOmap
FMMUc++;
}
context->slavelist[slave].FMMUunused = FMMUc;
/* Add one WKC for an input if flag is true */
if (AddToInputsWKC)
context->grouplist[group].inputsWKC++;
}
static void ecx_config_create_output_mappings(ecx_contextt *context, void *pIOmap,
uint8 group, int16 slave, uint32 * LogAddr, uint8 * BitPos)
{
int BitCount = 0;
int ByteCount = 0;
int FMMUsize = 0;
int FMMUdone = 0;
int AddToOutputsWKC = 0;
uint16 ByteCount = 0;
uint16 FMMUsize = 0;
uint8 SMc = 0;
uint16 EndAddr;
uint16 SMlength;
@ -1094,7 +1101,7 @@ static void ecx_config_create_output_mappings(ecx_contextt *context, void *pIOma
*LogAddr += 1;
*BitPos -= 8;
}
FMMUsize = *LogAddr - etohl(context->slavelist[slave].FMMU[FMMUc].LogStart) + 1;
FMMUsize = (uint16)(*LogAddr - etohl(context->slavelist[slave].FMMU[FMMUc].LogStart) + 1);
context->slavelist[slave].FMMU[FMMUc].LogLength = htoes(FMMUsize);
context->slavelist[slave].FMMU[FMMUc].LogEndbit = *BitPos;
*BitPos += 1;
@ -1118,7 +1125,7 @@ static void ecx_config_create_output_mappings(ecx_contextt *context, void *pIOma
FMMUsize = ByteCount;
if ((FMMUsize + FMMUdone)> (int)context->slavelist[slave].Obytes)
{
FMMUsize = context->slavelist[slave].Obytes - FMMUdone;
FMMUsize = (uint16)(context->slavelist[slave].Obytes - FMMUdone);
}
*LogAddr += FMMUsize;
context->slavelist[slave].FMMU[FMMUc].LogLength = htoes(FMMUsize);
@ -1126,13 +1133,18 @@ static void ecx_config_create_output_mappings(ecx_contextt *context, void *pIOma
*BitPos = 0;
}
FMMUdone += FMMUsize;
context->slavelist[slave].FMMU[FMMUc].PhysStartBit = 0;
context->slavelist[slave].FMMU[FMMUc].FMMUtype = 2;
context->slavelist[slave].FMMU[FMMUc].FMMUactive = 1;
/* program FMMU for output */
ecx_FPWR(context->port, configadr, ECT_REG_FMMU0 + (sizeof(ec_fmmut) * FMMUc),
sizeof(ec_fmmut), &(context->slavelist[slave].FMMU[FMMUc]), EC_TIMEOUTRET3);
context->grouplist[group].outputsWKC++;
if (context->slavelist[slave].FMMU[FMMUc].LogLength)
{
context->slavelist[slave].FMMU[FMMUc].PhysStartBit = 0;
context->slavelist[slave].FMMU[FMMUc].FMMUtype = 2;
context->slavelist[slave].FMMU[FMMUc].FMMUactive = 1;
/* program FMMU for output */
ecx_FPWR(context->port, configadr, ECT_REG_FMMU0 + (sizeof(ec_fmmut) * FMMUc),
sizeof(ec_fmmut), &(context->slavelist[slave].FMMU[FMMUc]), EC_TIMEOUTRET3);
/* Set flag to add one for an output FMMU,
a single ESC can only contribute once */
AddToOutputsWKC = 1;
}
if (!context->slavelist[slave].outputs)
{
if (group)
@ -1158,6 +1170,9 @@ static void ecx_config_create_output_mappings(ecx_contextt *context, void *pIOma
FMMUc++;
}
context->slavelist[slave].FMMUunused = FMMUc;
/* Add one WKC for an output if flag is true */
if (AddToOutputsWKC)
context->grouplist[group].outputsWKC++;
}
/** Map all PDOs in one group of slaves to IOmap with Outputs/Inputs
@ -1244,7 +1259,7 @@ int ecx_config_map_group(ecx_contextt *context, void *pIOmap, uint8 group)
context->grouplist[group].Obytes = LogAddr - context->grouplist[group].logstartaddr;
context->grouplist[group].nsegments = currentsegment + 1;
context->grouplist[group].Isegment = currentsegment;
context->grouplist[group].Ioffset = segmentsize;
context->grouplist[group].Ioffset = (uint16)segmentsize;
if (!group)
{
context->slavelist[0].outputs = pIOmap;

View File

@ -61,7 +61,7 @@ int ecx_EOEdefinehook(ecx_contextt *context, void *hook)
* @param[in] slave = Slave number
* @param[in] port = Port number on slave if applicable
* @param[in] ipparam = IP parameter data to be sent
* @param[in] Timeout = Timeout in us, standard is EC_TIMEOUTRXM
* @param[in] timeout = Timeout in us, standard is EC_TIMEOUTRXM
* @return Workcounter from last slave response or returned result code
*/
int ecx_EOEsetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t * ipparam, int timeout)
@ -87,52 +87,50 @@ int ecx_EOEsetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
cnt = ec_nextmbxcnt(context->slavelist[slave].mbx_cnt);
context->slavelist[slave].mbx_cnt = cnt;
EOEp->mbxheader.mbxtype = ECT_MBXT_EOE + (cnt << 4); /* EoE */
EOEp->mbxheader.mbxtype = ECT_MBXT_EOE + MBX_HDR_SET_CNT(cnt); /* EoE */
EOEp->frameinfo1 = htoes(EOE_HDR_FRAME_TYPE_SET(EOE_INIT_REQ) |
EOEp->frameinfo1 = htoes(EOE_HDR_FRAME_TYPE_SET(EOE_INIT_REQ) |
EOE_HDR_FRAME_PORT_SET(port) |
EOE_HDR_LAST_FRAGMENT);
EOEp->frameinfo2 = 0;
/* The EoE frame will include "empty" IP/DNS entries, makes wireshark happy.
* Specification say they are optional, TwinCAT include empty entries.
*/
if (ipparam->mac_set)
{
flags |= EOE_PARAM_MAC_INCLUDE;
memcpy(&EOEp->data[data_offset], ipparam->mac.addr, EOE_ETHADDR_LENGTH);
data_offset += EOE_ETHADDR_LENGTH;
}
data_offset += EOE_ETHADDR_LENGTH;
if (ipparam->ip_set)
{
flags |= EOE_PARAM_IP_INCLUDE;
EOE_ip_uint32_to_byte(&ipparam->ip, &EOEp->data[data_offset]);
data_offset += EOE_IP4_LENGTH;
}
data_offset += 4;
if (ipparam->subnet_set)
{
flags |= EOE_PARAM_SUBNET_IP_INCLUDE;
EOE_ip_uint32_to_byte(&ipparam->subnet, &EOEp->data[data_offset]);
data_offset += EOE_IP4_LENGTH;
}
data_offset += 4;
if (ipparam->default_gateway_set)
{
flags |= EOE_PARAM_DEFAULT_GATEWAY_INCLUDE;
EOE_ip_uint32_to_byte(&ipparam->default_gateway, &EOEp->data[data_offset]);
data_offset += EOE_IP4_LENGTH;
}
data_offset += 4;
if (ipparam->dns_ip_set)
{
flags |= EOE_PARAM_DNS_IP_INCLUDE;
EOE_ip_uint32_to_byte(&ipparam->dns_ip, &EOEp->data[data_offset]);
data_offset += EOE_IP4_LENGTH;
}
data_offset += 4;
if (ipparam->dns_name_set)
{
/* TwinCAT include EOE_DNS_NAME_LENGTH chars even if name is shorter */
flags |= EOE_PARAM_DNS_NAME_INCLUDE;
memcpy(&EOEp->data[data_offset], (void *)ipparam->dns_name, EOE_DNS_NAME_LENGTH);
data_offset += EOE_DNS_NAME_LENGTH;
}
data_offset += EOE_DNS_NAME_LENGTH;
EOEp->mbxheader.length = htoes(EOE_PARAM_OFFSET + data_offset);
EOEp->data[0] = flags;
@ -175,7 +173,7 @@ int ecx_EOEsetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
* @param[in] slave = Slave number
* @param[in] port = Port number on slave if applicable
* @param[out] ipparam = IP parameter data retrived from slave
* @param[in] Timeout = Timeout in us, standard is EC_TIMEOUTRXM
* @param[in] timeout = Timeout in us, standard is EC_TIMEOUTRXM
* @return Workcounter from last slave response or returned result code
*/
int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t * ipparam, int timeout)
@ -200,9 +198,9 @@ int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
cnt = ec_nextmbxcnt(context->slavelist[slave].mbx_cnt);
context->slavelist[slave].mbx_cnt = cnt;
EOEp->mbxheader.mbxtype = ECT_MBXT_EOE + (cnt << 4); /* EoE */
EOEp->mbxheader.mbxtype = ECT_MBXT_EOE + MBX_HDR_SET_CNT(cnt); /* EoE */
EOEp->frameinfo1 = htoes(EOE_HDR_FRAME_TYPE_SET(EOE_GET_IP_PARAM_REQ) |
EOEp->frameinfo1 = htoes(EOE_HDR_FRAME_TYPE_SET(EOE_GET_IP_PARAM_REQ) |
EOE_HDR_FRAME_PORT_SET(port) |
EOE_HDR_LAST_FRAGMENT);
EOEp->frameinfo2 = 0;
@ -231,10 +229,6 @@ int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
}
else
{
/* The EoE frame will include "empty" IP/DNS entries, makes
* wireshark happy. Specification say they are optional, TwinCAT
* include empty entries.
*/
flags = aEOEp->data[0];
if (flags & EOE_PARAM_MAC_INCLUDE)
{
@ -242,36 +236,36 @@ int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
&aEOEp->data[data_offset],
EOE_ETHADDR_LENGTH);
ipparam->mac_set = 1;
data_offset += EOE_ETHADDR_LENGTH;
}
data_offset += EOE_ETHADDR_LENGTH;
if (flags & EOE_PARAM_IP_INCLUDE)
{
EOE_ip_byte_to_uint32(&aEOEp->data[data_offset],
&ipparam->ip);
ipparam->ip_set = 1;
data_offset += EOE_IP4_LENGTH;
}
data_offset += 4;
if (flags & EOE_PARAM_SUBNET_IP_INCLUDE)
{
EOE_ip_byte_to_uint32(&aEOEp->data[data_offset],
&ipparam->subnet);
ipparam->subnet_set = 1;
data_offset += EOE_IP4_LENGTH;
}
data_offset += 4;
if (flags & EOE_PARAM_DEFAULT_GATEWAY_INCLUDE)
{
EOE_ip_byte_to_uint32(&aEOEp->data[data_offset],
&ipparam->default_gateway);
ipparam->default_gateway_set = 1;
data_offset += EOE_IP4_LENGTH;
}
data_offset += 4;
if (flags & EOE_PARAM_DNS_IP_INCLUDE)
{
EOE_ip_byte_to_uint32(&aEOEp->data[data_offset],
&ipparam->dns_ip);
ipparam->dns_ip_set = 1;
data_offset += EOE_IP4_LENGTH;
}
data_offset += 4;
if (flags & EOE_PARAM_DNS_NAME_INCLUDE)
{
uint16_t dns_len;
@ -286,8 +280,8 @@ int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
/* Assume ZERO terminated string */
memcpy(ipparam->dns_name, &aEOEp->data[data_offset], dns_len);
ipparam->dns_name_set = 1;
data_offset += EOE_DNS_NAME_LENGTH;
}
data_offset += EOE_DNS_NAME_LENGTH;
/* Something os not correct, flag the error */
if(data_offset > eoedatasize)
{
@ -316,7 +310,7 @@ int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
* @param[in] port = Port number on slave if applicable
* @param[in] psize = Size in bytes of parameter buffer.
* @param[in] p = Pointer to parameter buffer
* @param[in] Timeout = Timeout in us, standard is EC_TIMEOUTRXM
* @param[in] timeout = Timeout in us, standard is EC_TIMEOUTRXM
* @return Workcounter from last slave transmission
*/
int ecx_EOEsend(ecx_contextt *context, uint16 slave, uint8 port, int psize, void *p, int timeout)
@ -324,10 +318,9 @@ int ecx_EOEsend(ecx_contextt *context, uint16 slave, uint8 port, int psize, void
ec_EOEt *EOEp;
ec_mbxbuft MbxOut;
uint16 frameinfo1, frameinfo2;
uint16 txframesize, txframeoffset;
uint8 cnt, txfragmentno;
boolean NotLast;
int wkc, maxdata;
int wkc, maxdata, txframesize, txframeoffset;
const uint8 * buf = p;
static uint8_t txframeno = 0;
@ -377,8 +370,8 @@ int ecx_EOEsend(ecx_contextt *context, uint16 slave, uint8 port, int psize, void
cnt = ec_nextmbxcnt(context->slavelist[slave].mbx_cnt);
context->slavelist[slave].mbx_cnt = cnt;
EOEp->mbxheader.length = htoes(4 + txframesize); /* no timestamp */
EOEp->mbxheader.mbxtype = ECT_MBXT_EOE + (cnt << 4); /* EoE */
EOEp->mbxheader.length = htoes((uint16)(4 + txframesize)); /* no timestamp */
EOEp->mbxheader.mbxtype = ECT_MBXT_EOE + MBX_HDR_SET_CNT(cnt); /* EoE */
EOEp->frameinfo1 = htoes(frameinfo1);
EOEp->frameinfo2 = htoes(frameinfo2);
@ -407,7 +400,7 @@ int ecx_EOEsend(ecx_contextt *context, uint16 slave, uint8 port, int psize, void
* @param[in] context = context struct
* @param[in] slave = Slave number
* @param[in] port = Port number on slave if applicable
* @param[in/out] psize = Size in bytes of parameter buffer.
* @param[in,out] psize = Size in bytes of parameter buffer.
* @param[in] p = Pointer to parameter buffer
* @param[in] timeout = Timeout in us, standard is EC_TIMEOUTRXM
* @return Workcounter from last slave response or error code
@ -416,10 +409,10 @@ int ecx_EOErecv(ecx_contextt *context, uint16 slave, uint8 port, int * psize, vo
{
ec_EOEt *aEOEp;
ec_mbxbuft MbxIn;
uint16 frameinfo1, frameinfo2, rxframesize, rxframeoffset, eoedatasize;
uint16 frameinfo1, frameinfo2;
uint8 rxfragmentno, rxframeno;
boolean NotLast;
int wkc, buffersize;
int wkc, buffersize, rxframesize, rxframeoffset, eoedatasize;
uint8 * buf = p;
ec_clearmbx(&MbxIn);
@ -523,11 +516,11 @@ int ecx_EOErecv(ecx_contextt *context, uint16 slave, uint8 port, int * psize, vo
* Ethernet frame buffer at given offset and update current fragment variables
*
* @param[in] MbxIn = Received mailbox containing fragment data
* @param[in/out] rxfragmentno = Fragment number
* @param[in/out] rxframesize = Frame size
* @param[in/out] rxframeoffset = Frame offset
* @param[in/out] rxframeno = Frame number
* @param[in/out] psize = Size in bytes of frame buffer.
* @param[in,out] rxfragmentno = Fragment number
* @param[in,out] rxframesize = Frame size
* @param[in,out] rxframeoffset = Frame offset
* @param[in,out] rxframeno = Frame number
* @param[in,out] psize = Size in bytes of frame buffer.
* @param[out] p = Pointer to frame buffer
* @return 0= if fragment OK, >0 if last fragment, <0 on error
*/
@ -579,7 +572,7 @@ int ecx_EOEreadfragment(
/* Is it a new frame?*/
if (*rxfragmentno == 0)
{
*rxframesize = (EOE_HDR_FRAME_OFFSET_GET(frameinfo2) << 5);
*rxframesize = (uint16)(EOE_HDR_FRAME_OFFSET_GET(frameinfo2) << 5);
*rxframeoffset = 0;
*rxframeno = EOE_HDR_FRAME_NO_GET(frameinfo2);
}

View File

@ -18,10 +18,15 @@ extern "C"
#include <ethercattype.h>
/* use maximum size for EOE mailbox data */
#define EC_MAXEOEDATA EC_MAXMBX
/** DNS length according to ETG 1000.6 */
#define EOE_DNS_NAME_LENGTH 32
/** Ethernet address length not including VLAN */
#define EOE_ETHADDR_LENGTH 6
/** IPv4 address length */
#define EOE_IP4_LENGTH sizeof(uint32_t)
#define EOE_MAKEU32(a,b,c,d) (((uint32_t)((a) & 0xff) << 24) | \
((uint32_t)((b) & 0xff) << 16) | \
@ -61,7 +66,7 @@ extern "C"
#define EOE_HDR_FRAME_TYPE_GET(x) (((x) >> 0) & 0xF)
#define EOE_HDR_FRAME_PORT_OFFSET 4
#define EOE_HDR_FRAME_PORT (0xF << 4)
#define EOE_HDR_FRAME_PORT_SET(x) (((x) & 0xF) << 4)
#define EOE_HDR_FRAME_PORT_SET(x) ((uint16)(((x) & 0xF) << 4))
#define EOE_HDR_FRAME_PORT_GET(x) (((x) >> 4) & 0xF)
#define EOE_HDR_LAST_FRAGMENT_OFFSET 8
#define EOE_HDR_LAST_FRAGMENT (0x1 << 8)
@ -79,15 +84,15 @@ extern "C"
/** Header frame info 2 */
#define EOE_HDR_FRAG_NO_OFFSET 0
#define EOE_HDR_FRAG_NO (0x3F << 0)
#define EOE_HDR_FRAG_NO_SET(x) (((x) & 0x3F) << 0)
#define EOE_HDR_FRAG_NO_SET(x) ((uint16)(((x) & 0x3F) << 0))
#define EOE_HDR_FRAG_NO_GET(x) (((x) >> 0) & 0x3F)
#define EOE_HDR_FRAME_OFFSET_OFFSET 6
#define EOE_HDR_FRAME_OFFSET (0x3F << 6)
#define EOE_HDR_FRAME_OFFSET_SET(x) (((x) & 0x3F) << 6)
#define EOE_HDR_FRAME_OFFSET_SET(x) ((uint16)(((x) & 0x3F) << 6))
#define EOE_HDR_FRAME_OFFSET_GET(x) (((x) >> 6) & 0x3F)
#define EOE_HDR_FRAME_NO_OFFSET 12
#define EOE_HDR_FRAME_NO (0xF << 12)
#define EOE_HDR_FRAME_NO_SET(x) (((x) & 0xF) << 12)
#define EOE_HDR_FRAME_NO_SET(x) ((uint16)(((x) & 0xF) << 12))
#define EOE_HDR_FRAME_NO_GET(x) (((x) >> 12) & 0xF)
/** EOE param */
@ -163,7 +168,7 @@ typedef struct PACKED
uint16_t frameinfo2;
uint16_t result;
};
uint8 data[0];
uint8 data[EC_MAXEOEDATA];
} ec_EOEt;
PACKED_END

View File

@ -98,7 +98,7 @@ int ecx_FOEread(ecx_contextt *context, uint16 slave, char *filename, uint32 pass
/* get new mailbox count value, used as session handle */
cnt = ec_nextmbxcnt(context->slavelist[slave].mbx_cnt);
context->slavelist[slave].mbx_cnt = cnt;
FOEp->MbxHeader.mbxtype = ECT_MBXT_FOE + (cnt << 4); /* FoE */
FOEp->MbxHeader.mbxtype = ECT_MBXT_FOE + MBX_HDR_SET_CNT(cnt); /* FoE */
FOEp->OpCode = ECT_FOE_READ;
FOEp->Password = htoel(password);
/* copy filename in mailbox */
@ -138,7 +138,7 @@ int ecx_FOEread(ecx_contextt *context, uint16 slave, char *filename, uint32 pass
/* get new mailbox count value */
cnt = ec_nextmbxcnt(context->slavelist[slave].mbx_cnt);
context->slavelist[slave].mbx_cnt = cnt;
FOEp->MbxHeader.mbxtype = ECT_MBXT_FOE + (cnt << 4); /* FoE */
FOEp->MbxHeader.mbxtype = ECT_MBXT_FOE + MBX_HDR_SET_CNT(cnt); /* FoE */
FOEp->OpCode = ECT_FOE_ACK;
FOEp->PacketNumber = htoel(packetnumber);
/* send FoE ack to slave */
@ -227,7 +227,7 @@ int ecx_FOEwrite(ecx_contextt *context, uint16 slave, char *filename, uint32 pas
/* get new mailbox count value, used as session handle */
cnt = ec_nextmbxcnt(context->slavelist[slave].mbx_cnt);
context->slavelist[slave].mbx_cnt = cnt;
FOEp->MbxHeader.mbxtype = ECT_MBXT_FOE + (cnt << 4); /* FoE */
FOEp->MbxHeader.mbxtype = ECT_MBXT_FOE + MBX_HDR_SET_CNT(cnt); /* FoE */
FOEp->OpCode = ECT_FOE_WRITE;
FOEp->Password = htoel(password);
/* copy filename in mailbox */
@ -276,13 +276,13 @@ int ecx_FOEwrite(ecx_contextt *context, uint16 slave, char *filename, uint32 pas
{
dofinalzero = TRUE;
}
FOEp->MbxHeader.length = htoes(0x0006 + segmentdata);
FOEp->MbxHeader.length = htoes((uint16)(0x0006 + segmentdata));
FOEp->MbxHeader.address = htoes(0x0000);
FOEp->MbxHeader.priority = 0x00;
/* get new mailbox count value */
cnt = ec_nextmbxcnt(context->slavelist[slave].mbx_cnt);
context->slavelist[slave].mbx_cnt = cnt;
FOEp->MbxHeader.mbxtype = ECT_MBXT_FOE + (cnt << 4); /* FoE */
FOEp->MbxHeader.mbxtype = ECT_MBXT_FOE + MBX_HDR_SET_CNT(cnt); /* FoE */
FOEp->OpCode = ECT_FOE_DATA;
sendpacket++;
FOEp->PacketNumber = htoel(sendpacket);

View File

@ -110,8 +110,6 @@ ecx_contextt ecx_context = {
&ec_elist, // .elist =
&ec_idxstack, // .idxstack =
&EcatError, // .ecaterror =
0, // .DCtO =
0, // .DCl =
&ec_DCtime, // .DCtime =
&ec_SMcommtype[0], // .SMcommtype =
&ec_PDOassign[0], // .PDOassign =
@ -349,7 +347,7 @@ uint8 ecx_siigetbyte(ecx_contextt *context, uint16 slave, uint16 address)
if (address < EC_MAXEEPBUF)
{
mapw = address >> 5;
mapb = address - (mapw << 5);
mapb = (uint16)(address - (mapw << 5));
if (context->esimap[mapw] & (uint32)(1 << mapb))
{
/* byte is already in buffer */
@ -377,7 +375,7 @@ uint8 ecx_siigetbyte(ecx_contextt *context, uint16 slave, uint16 address)
}
/* find bitmap location */
mapw = eadr >> 4;
mapb = (eadr << 1) - (mapw << 5);
mapb = (uint16)((eadr << 1) - (mapw << 5));
for(lp = 0 ; lp < cnt ; lp++)
{
/* set bitmap for each byte that is read */
@ -552,7 +550,7 @@ uint16 ecx_siiSM(ecx_contextt *context, uint16 slave, ec_eepromSMt* SM)
a = SM->Startpos;
w = ecx_siigetbyte(context, slave, a++);
w += (ecx_siigetbyte(context, slave, a++) << 8);
SM->nSM = (w / 4);
SM->nSM = (uint8)(w / 4);
SM->PhStart = ecx_siigetbyte(context, slave, a++);
SM->PhStart += (ecx_siigetbyte(context, slave, a++) << 8);
SM->Plength = ecx_siigetbyte(context, slave, a++);
@ -611,7 +609,7 @@ uint16 ecx_siiSMnext(ecx_contextt *context, uint16 slave, ec_eepromSMt* SM, uint
* @param[in] t = 0=RXPDO 1=TXPDO
* @return mapping size in bits of PDO
*/
int ecx_siiPDO(ecx_contextt *context, uint16 slave, ec_eepromPDOt* PDO, uint8 t)
uint32 ecx_siiPDO(ecx_contextt *context, uint16 slave, ec_eepromPDOt* PDO, uint8 t)
{
uint16 a , w, c, e, er, Size;
uint8 eectl = context->slavelist[slave].eep_pdi;
@ -685,7 +683,7 @@ int ecx_FPRD_multi(ecx_contextt *context, int n, uint16 *configlst, ec_alstatust
int wkc;
uint8 idx;
ecx_portt *port;
int sldatapos[MAX_FPRD_MULTI];
uint16 sldatapos[MAX_FPRD_MULTI];
int slcnt;
port = context->port;
@ -789,7 +787,7 @@ int ecx_readstate(ecx_contextt *context)
fslave = 1;
do
{
lslave = *(context->slavecount);
lslave = (uint16)*(context->slavecount);
if ((lslave - fslave) >= MAX_FPRD_MULTI)
{
lslave = fslave + MAX_FPRD_MULTI - 1;
@ -1113,8 +1111,7 @@ int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int tim
*/
void ecx_esidump(ecx_contextt *context, uint16 slave, uint8 *esibuf)
{
int address, incr;
uint16 configadr;
uint16 configadr, address, incr;
uint64 *p64;
uint16 *p16;
uint64 edat;
@ -1242,7 +1239,8 @@ int ecx_eeprom2pdi(ecx_contextt *context, uint16 slave)
uint16 ecx_eeprom_waitnotbusyAP(ecx_contextt *context, uint16 aiadr,uint16 *estat, int timeout)
{
int wkc, cnt = 0, retval = 0;
int wkc, cnt = 0;
uint16 retval = 0;
osal_timert timer;
osal_timer_start(&timer, timeout);
@ -1411,7 +1409,8 @@ int ecx_writeeepromAP(ecx_contextt *context, uint16 aiadr, uint16 eeproma, uint1
uint16 ecx_eeprom_waitnotbusyFP(ecx_contextt *context, uint16 configadr,uint16 *estat, int timeout)
{
int wkc, cnt = 0, retval = 0;
int wkc, cnt = 0;
uint16 retval = 0;
osal_timert timer;
osal_timer_start(&timer, timeout);
@ -1641,14 +1640,16 @@ uint32 ecx_readeeprom2(ecx_contextt *context, uint16 slave, int timeout)
* @param[in] idx = Used datagram index.
* @param[in] data = Pointer to process data segment.
* @param[in] length = Length of data segment in bytes.
* @param[in] DCO = Offset position of DC frame.
*/
static void ecx_pushindex(ecx_contextt *context, uint8 idx, void *data, uint16 length)
static void ecx_pushindex(ecx_contextt *context, uint8 idx, void *data, uint16 length, uint16 DCO)
{
if(context->idxstack->pushed < EC_MAXBUF)
{
context->idxstack->idx[context->idxstack->pushed] = idx;
context->idxstack->data[context->idxstack->pushed] = data;
context->idxstack->length[context->idxstack->pushed] = length;
context->idxstack->dcoffset[context->idxstack->pushed] = DCO;
context->idxstack->pushed++;
}
}
@ -1691,19 +1692,22 @@ static void ecx_clearindex(ecx_contextt *context) {
* In order to recombine the slave response, a stack is used.
* @param[in] context = context struct
* @param[in] group = group number
* @param[in] use_overlap_io = flag if overlapped iomap is used
* @return >0 if processdata is transmitted.
*/
static int ecx_main_send_processdata(ecx_contextt *context, uint8 group, boolean use_overlap_io)
{
uint32 LogAdr;
uint16 w1, w2;
int length, sublength;
int length;
uint16 sublength;
uint8 idx;
int wkc;
uint8* data;
boolean first=FALSE;
uint16 currentsegment = 0;
uint32 iomapinputoffset;
uint16 DCO;
wkc = 0;
if(context->grouplist[group].hasdc)
@ -1746,22 +1750,22 @@ static int ecx_main_send_processdata(ecx_contextt *context, uint8 group, boolean
{
if(currentsegment == context->grouplist[group].Isegment)
{
sublength = context->grouplist[group].IOsegment[currentsegment++] - context->grouplist[group].Ioffset;
sublength = (uint16)(context->grouplist[group].IOsegment[currentsegment++] - context->grouplist[group].Ioffset);
}
else
{
sublength = context->grouplist[group].IOsegment[currentsegment++];
sublength = (uint16)context->grouplist[group].IOsegment[currentsegment++];
}
/* get new index */
idx = ecx_getindex(context->port);
w1 = LO_WORD(LogAdr);
w2 = HI_WORD(LogAdr);
DCO = 0;
ecx_setupdatagram(context->port, &(context->port->txbuf[idx]), EC_CMD_LRD, idx, w1, w2, sublength, data);
if(first)
{
context->DCl = sublength;
/* FPRMW in second datagram */
context->DCtO = ecx_adddatagram(context->port, &(context->port->txbuf[idx]), EC_CMD_FRMW, idx, FALSE,
DCO = ecx_adddatagram(context->port, &(context->port->txbuf[idx]), EC_CMD_FRMW, idx, FALSE,
context->slavelist[context->grouplist[group].DCnext].configadr,
ECT_REG_DCSYSTIME, sizeof(int64), context->DCtime);
first = FALSE;
@ -1769,7 +1773,7 @@ static int ecx_main_send_processdata(ecx_contextt *context, uint8 group, boolean
/* send frame */
ecx_outframe_red(context->port, idx);
/* push index and data pointer on stack */
ecx_pushindex(context, idx, data, sublength);
ecx_pushindex(context, idx, data, sublength, DCO);
length -= sublength;
LogAdr += sublength;
data += sublength;
@ -1785,21 +1789,21 @@ static int ecx_main_send_processdata(ecx_contextt *context, uint8 group, boolean
/* segment transfer if needed */
do
{
sublength = context->grouplist[group].IOsegment[currentsegment++];
sublength = (uint16)context->grouplist[group].IOsegment[currentsegment++];
if((length - sublength) < 0)
{
sublength = length;
sublength = (uint16)length;
}
/* get new index */
idx = ecx_getindex(context->port);
w1 = LO_WORD(LogAdr);
w2 = HI_WORD(LogAdr);
DCO = 0;
ecx_setupdatagram(context->port, &(context->port->txbuf[idx]), EC_CMD_LWR, idx, w1, w2, sublength, data);
if(first)
{
context->DCl = sublength;
/* FPRMW in second datagram */
context->DCtO = ecx_adddatagram(context->port, &(context->port->txbuf[idx]), EC_CMD_FRMW, idx, FALSE,
DCO = ecx_adddatagram(context->port, &(context->port->txbuf[idx]), EC_CMD_FRMW, idx, FALSE,
context->slavelist[context->grouplist[group].DCnext].configadr,
ECT_REG_DCSYSTIME, sizeof(int64), context->DCtime);
first = FALSE;
@ -1807,7 +1811,7 @@ static int ecx_main_send_processdata(ecx_contextt *context, uint8 group, boolean
/* send frame */
ecx_outframe_red(context->port, idx);
/* push index and data pointer on stack */
ecx_pushindex(context, idx, data, sublength);
ecx_pushindex(context, idx, data, sublength, DCO);
length -= sublength;
LogAdr += sublength;
data += sublength;
@ -1830,17 +1834,17 @@ static int ecx_main_send_processdata(ecx_contextt *context, uint8 group, boolean
/* segment transfer if needed */
do
{
sublength = context->grouplist[group].IOsegment[currentsegment++];
sublength = (uint16)context->grouplist[group].IOsegment[currentsegment++];
/* get new index */
idx = ecx_getindex(context->port);
w1 = LO_WORD(LogAdr);
w2 = HI_WORD(LogAdr);
DCO = 0;
ecx_setupdatagram(context->port, &(context->port->txbuf[idx]), EC_CMD_LRW, idx, w1, w2, sublength, data);
if(first)
{
context->DCl = sublength;
/* FPRMW in second datagram */
context->DCtO = ecx_adddatagram(context->port, &(context->port->txbuf[idx]), EC_CMD_FRMW, idx, FALSE,
DCO = ecx_adddatagram(context->port, &(context->port->txbuf[idx]), EC_CMD_FRMW, idx, FALSE,
context->slavelist[context->grouplist[group].DCnext].configadr,
ECT_REG_DCSYSTIME, sizeof(int64), context->DCtime);
first = FALSE;
@ -1852,7 +1856,7 @@ static int ecx_main_send_processdata(ecx_contextt *context, uint8 group, boolean
* in the IOmap if we use an overlapping IOmap. If a regular IOmap
* is used it should always be 0.
*/
ecx_pushindex(context, idx, (data + iomapinputoffset), sublength);
ecx_pushindex(context, idx, (data + iomapinputoffset), sublength, DCO);
length -= sublength;
LogAdr += sublength;
data += sublength;
@ -1908,56 +1912,57 @@ int ecx_send_processdata_group(ecx_contextt *context, uint8 group)
*/
int ecx_receive_processdata_group(ecx_contextt *context, uint8 group, int timeout)
{
int pos, idx;
uint8 idx;
int pos;
int wkc = 0, wkc2;
uint16 le_wkc = 0;
int valid_wkc = 0;
int64 le_DCtime;
boolean first = FALSE;
ec_idxstackT *idxstack;
ec_bufT *rxbuf;
if(context->grouplist[group].hasdc)
{
first = TRUE;
}
/* just to prevent compiler warning for unused group */
wkc2 = group;
idxstack = context->idxstack;
rxbuf = context->port->rxbuf;
/* get first index */
pos = ecx_pullindex(context);
/* read the same number of frames as send */
while (pos >= 0)
{
idx = context->idxstack->idx[pos];
wkc2 = ecx_waitinframe(context->port, context->idxstack->idx[pos], timeout);
idx = idxstack->idx[pos];
wkc2 = ecx_waitinframe(context->port, idx, timeout);
/* check if there is input data in frame */
if (wkc2 > EC_NOFRAME)
{
if((context->port->rxbuf[idx][EC_CMDOFFSET]==EC_CMD_LRD) || (context->port->rxbuf[idx][EC_CMDOFFSET]==EC_CMD_LRW))
if((rxbuf[idx][EC_CMDOFFSET]==EC_CMD_LRD) || (rxbuf[idx][EC_CMDOFFSET]==EC_CMD_LRW))
{
if(first)
if(idxstack->dcoffset[pos] > 0)
{
memcpy(context->idxstack->data[pos], &(context->port->rxbuf[idx][EC_HEADERSIZE]), context->DCl);
memcpy(&le_wkc, &(context->port->rxbuf[idx][EC_HEADERSIZE + context->DCl]), EC_WKCSIZE);
memcpy(idxstack->data[pos], &(rxbuf[idx][EC_HEADERSIZE]), idxstack->length[pos]);
memcpy(&le_wkc, &(rxbuf[idx][EC_HEADERSIZE + idxstack->length[pos]]), EC_WKCSIZE);
wkc = etohs(le_wkc);
memcpy(&le_DCtime, &(context->port->rxbuf[idx][context->DCtO]), sizeof(le_DCtime));
memcpy(&le_DCtime, &(rxbuf[idx][idxstack->dcoffset[pos]]), sizeof(le_DCtime));
*(context->DCtime) = etohll(le_DCtime);
first = FALSE;
}
else
{
/* copy input data back to process data buffer */
memcpy(context->idxstack->data[pos], &(context->port->rxbuf[idx][EC_HEADERSIZE]), context->idxstack->length[pos]);
memcpy(idxstack->data[pos], &(rxbuf[idx][EC_HEADERSIZE]), idxstack->length[pos]);
wkc += wkc2;
}
valid_wkc = 1;
}
else if(context->port->rxbuf[idx][EC_CMDOFFSET]==EC_CMD_LWR)
else if(rxbuf[idx][EC_CMDOFFSET]==EC_CMD_LWR)
{
if(first)
if(idxstack->dcoffset[pos] > 0)
{
memcpy(&le_wkc, &(context->port->rxbuf[idx][EC_HEADERSIZE + context->DCl]), EC_WKCSIZE);
memcpy(&le_wkc, &(rxbuf[idx][EC_HEADERSIZE + idxstack->length[pos]]), EC_WKCSIZE);
/* output WKC counts 2 times when using LRW, emulate the same for LWR */
wkc = etohs(le_wkc) * 2;
memcpy(&le_DCtime, &(context->port->rxbuf[idx][context->DCtO]), sizeof(le_DCtime));
memcpy(&le_DCtime, &(rxbuf[idx][idxstack->dcoffset[pos]]), sizeof(le_DCtime));
*(context->DCtime) = etohll(le_DCtime);
first = FALSE;
}
else
{
@ -2125,7 +2130,7 @@ uint16 ec_siiSMnext(uint16 slave, ec_eepromSMt* SM, uint16 n)
* @return mapping size in bits of PDO
* @see ecx_siiPDO
*/
int ec_siiPDO(uint16 slave, ec_eepromPDOt* PDO, uint8 t)
uint32 ec_siiPDO(uint16 slave, ec_eepromPDOt* PDO, uint8 t)
{
return ecx_siiPDO (&ecx_context, slave, PDO, t);
}
@ -2356,7 +2361,6 @@ int ec_send_processdata_group(uint8 group)
* In contrast to the base LRW function this function is non-blocking.
* If the processdata does not fit in one datagram, multiple are used.
* In order to recombine the slave response, a stack is used.
* @param[in] context = context struct
* @param[in] group = group number
* @return >0 if processdata is transmitted.
* @see ecx_send_overlap_processdata_group

View File

@ -340,6 +340,7 @@ typedef struct ec_idxstack
uint8 idx[EC_MAXBUF];
void *data[EC_MAXBUF];
uint16 length[EC_MAXBUF];
uint16 dcoffset[EC_MAXBUF];
} ec_idxstackT;
/** ringbuf for error storage */
@ -407,10 +408,6 @@ struct ecx_context
ec_idxstackT *idxstack;
/** reference to ecaterror state */
boolean *ecaterror;
/** internal, position of DC datagram in process data packet */
uint16 DCtO;
/** internal, length of DC datagram */
uint16 DCl;
/** reference to last DC time from slaves */
int64 *DCtime;
/** internal, SM buffer */
@ -456,7 +453,7 @@ void ec_siistring(char *str, uint16 slave, uint16 Sn);
uint16 ec_siiFMMU(uint16 slave, ec_eepromFMMUt* FMMU);
uint16 ec_siiSM(uint16 slave, ec_eepromSMt* SM);
uint16 ec_siiSMnext(uint16 slave, ec_eepromSMt* SM, uint16 n);
int ec_siiPDO(uint16 slave, ec_eepromPDOt* PDO, uint8 t);
uint32 ec_siiPDO(uint16 slave, ec_eepromPDOt* PDO, uint8 t);
int ec_readstate(void);
int ec_writestate(uint16 slave);
uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout);
@ -499,7 +496,7 @@ void ecx_siistring(ecx_contextt *context, char *str, uint16 slave, uint16 Sn);
uint16 ecx_siiFMMU(ecx_contextt *context, uint16 slave, ec_eepromFMMUt* FMMU);
uint16 ecx_siiSM(ecx_contextt *context, uint16 slave, ec_eepromSMt* SM);
uint16 ecx_siiSMnext(ecx_contextt *context, uint16 slave, ec_eepromSMt* SM, uint16 n);
int ecx_siiPDO(ecx_contextt *context, uint16 slave, ec_eepromPDOt* PDO, uint8 t);
uint32 ecx_siiPDO(ecx_contextt *context, uint16 slave, ec_eepromPDOt* PDO, uint8 t);
int ecx_readstate(ecx_contextt *context);
int ecx_writestate(ecx_contextt *context, uint16 slave);
uint16 ecx_statecheck(ecx_contextt *context, uint16 slave, uint16 reqstate, int timeout);

View File

@ -78,7 +78,7 @@ void ecx_SoEerror(ecx_contextt *context, uint16 Slave, uint16 idn, uint16 Error)
int ecx_SoEread(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 elementflags, uint16 idn, int *psize, void *p, int timeout)
{
ec_SoEt *SoEp, *aSoEp;
uint16 totalsize, framedatasize;
int totalsize, framedatasize;
int wkc;
uint8 *bp;
uint8 *mp;
@ -99,7 +99,7 @@ int ecx_SoEread(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 elemen
/* get new mailbox count value, used as session handle */
cnt = ec_nextmbxcnt(context->slavelist[slave].mbx_cnt);
context->slavelist[slave].mbx_cnt = cnt;
SoEp->MbxHeader.mbxtype = ECT_MBXT_SOE + (cnt << 4); /* SoE */
SoEp->MbxHeader.mbxtype = ECT_MBXT_SOE + MBX_HDR_SET_CNT(cnt); /* SoE */
SoEp->opCode = ECT_SOE_READREQ;
SoEp->incomplete = 0;
SoEp->error = 0;
@ -200,7 +200,7 @@ int ecx_SoEread(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 elemen
int ecx_SoEwrite(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 elementflags, uint16 idn, int psize, void *p, int timeout)
{
ec_SoEt *SoEp, *aSoEp;
uint16 framedatasize, maxdata;
int framedatasize, maxdata;
int wkc;
uint8 *mp;
uint8 *hp;
@ -236,13 +236,13 @@ int ecx_SoEwrite(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 eleme
framedatasize = maxdata; /* segmented transfer needed */
NotLast = TRUE;
SoEp->incomplete = 1;
SoEp->fragmentsleft = psize / maxdata;
SoEp->fragmentsleft = (uint16)(psize / maxdata);
}
SoEp->MbxHeader.length = htoes(sizeof(ec_SoEt) - sizeof(ec_mbxheadert) + framedatasize);
SoEp->MbxHeader.length = htoes((uint16)(sizeof(ec_SoEt) - sizeof(ec_mbxheadert) + framedatasize));
/* get new mailbox counter, used for session handle */
cnt = ec_nextmbxcnt(context->slavelist[slave].mbx_cnt);
context->slavelist[slave].mbx_cnt = cnt;
SoEp->MbxHeader.mbxtype = ECT_MBXT_SOE + (cnt << 4); /* SoE */
SoEp->MbxHeader.mbxtype = ECT_MBXT_SOE + MBX_HDR_SET_CNT(cnt); /* SoE */
/* copy parameter data to mailbox */
memcpy(mp, hp, framedatasize);
hp += framedatasize;
@ -309,12 +309,12 @@ int ecx_SoEwrite(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 eleme
* @param[out] Isize = Size in bits of input mapping (AT) found
* @return >0 if mapping successful.
*/
int ecx_readIDNmap(ecx_contextt *context, uint16 slave, int *Osize, int *Isize)
int ecx_readIDNmap(ecx_contextt *context, uint16 slave, uint32 *Osize, uint32 *Isize)
{
int retVal = 0;
int wkc;
int psize;
int driveNr;
uint8 driveNr;
uint16 entries, itemcount;
ec_SoEmappingt SoEmapping;
ec_SoEattributet SoEattribute;
@ -329,7 +329,7 @@ int ecx_readIDNmap(ecx_contextt *context, uint16 slave, int *Osize, int *Isize)
if ((wkc > 0) && (psize >= 4) && ((entries = etohs(SoEmapping.currentlength) / 2) > 0) && (entries <= EC_SOE_MAXMAPPING))
{
/* command word (uint16) is always mapped but not in list */
*Osize = 16;
*Osize += 16;
for (itemcount = 0 ; itemcount < entries ; itemcount++)
{
psize = sizeof(SoEattribute);
@ -348,7 +348,7 @@ int ecx_readIDNmap(ecx_contextt *context, uint16 slave, int *Osize, int *Isize)
if ((wkc > 0) && (psize >= 4) && ((entries = etohs(SoEmapping.currentlength) / 2) > 0) && (entries <= EC_SOE_MAXMAPPING))
{
/* status word (uint16) is always mapped but not in list */
*Isize = 16;
*Isize += 16;
for (itemcount = 0 ; itemcount < entries ; itemcount++)
{
psize = sizeof(SoEattribute);
@ -382,7 +382,7 @@ int ec_SoEwrite(uint16 slave, uint8 driveNo, uint8 elementflags, uint16 idn, int
return ecx_SoEwrite(&ecx_context, slave, driveNo, elementflags, idn, psize, p, timeout);
}
int ec_readIDNmap(uint16 slave, int *Osize, int *Isize)
int ec_readIDNmap(uint16 slave, uint32 *Osize, uint32 *Isize)
{
return ecx_readIDNmap(&ecx_context, slave, Osize, Isize);
}

View File

@ -116,12 +116,12 @@ PACKED_END
#ifdef EC_VER1
int ec_SoEread(uint16 slave, uint8 driveNo, uint8 elementflags, uint16 idn, int *psize, void *p, int timeout);
int ec_SoEwrite(uint16 slave, uint8 driveNo, uint8 elementflags, uint16 idn, int psize, void *p, int timeout);
int ec_readIDNmap(uint16 slave, int *Osize, int *Isize);
int ec_readIDNmap(uint16 slave, uint32 *Osize, uint32 *Isize);
#endif
int ecx_SoEread(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 elementflags, uint16 idn, int *psize, void *p, int timeout);
int ecx_SoEwrite(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 elementflags, uint16 idn, int psize, void *p, int timeout);
int ecx_readIDNmap(ecx_contextt *context, uint16 slave, int *Osize, int *Isize);
int ecx_readIDNmap(ecx_contextt *context, uint16 slave, uint32 *Osize, uint32 *Isize);
#ifdef __cplusplus
}

View File

@ -506,6 +506,10 @@ typedef struct
} ec_errort;
/** Helper macros */
/** Set the count value in the Mailbox header */
#define MBX_HDR_SET_CNT(cnt) ((uint8)((cnt) << 4))
/** Macro to make a word from 2 bytes */
#define MK_WORD(msb, lsb) ((((uint16)(msb))<<8) | (lsb))
/** Macro to get hi byte of a word */

View File

@ -164,7 +164,7 @@ void add_timespec(struct timespec *ts, int64 addtime)
sec = (addtime - nsec) / NSEC_PER_SEC;
ts->tv_sec += sec;
ts->tv_nsec += nsec;
if ( ts->tv_nsec > NSEC_PER_SEC )
if ( ts->tv_nsec >= NSEC_PER_SEC )
{
nsec = ts->tv_nsec % NSEC_PER_SEC;
ts->tv_sec += (ts->tv_nsec - nsec) / NSEC_PER_SEC;

View File

@ -139,7 +139,7 @@ void simpletest(char *ifname)
}
else
{
printf("No socket connection on %s\nExcecute as root\n",ifname);
printf("No socket connection on %s\nExecute as root\n",ifname);
}
}

View File

@ -142,7 +142,7 @@ void add_timespec(struct timespec *ts, int64 addtime)
sec = (addtime - nsec) / NSEC_PER_SEC;
ts->tv_sec += sec;
ts->tv_nsec += nsec;
if ( ts->tv_nsec > NSEC_PER_SEC )
if ( ts->tv_nsec >= NSEC_PER_SEC )
{
nsec = ts->tv_nsec % NSEC_PER_SEC;
ts->tv_sec += (ts->tv_nsec - nsec) / NSEC_PER_SEC;