Comments (15)
The problem is that this code handles the fact when opener is blocked by the operating system longer then the OPENER_TIMER_TICK. This helps to keep the overall timing behavior stable. The problem now with step changes is that this code wants to compensate for the step change. Because for OpENer it looks like the operating system has blocked OpENer for a long time.
In order to handle this correctly the process of making the step change would need to update lasttime. or that the getmilliseconds uses a timer which is not effected by the step change.
from opener.
I do not see why multiple calls to manageConnections() (in a busy loop) is the right thing to do.
How about passing "elapsedtime" to manageConnections() so the "InnacitvityWatchdogTimer" and "TransmissionTriggerTimer" are updated all at once and changing "while" to an "if"? Then TheNetworkStatus.elapsedtime can be zeroed.
from opener.
Never thought about given the full time elapsed to manageConnections. Maybe even passing the current time could help simplifying the implementations of the timers because now instead of performing calculations every time only simple comparisons could be done.
This would at least help if the step change is positive. For negative step changes a different solution needs to be found.
Also applications depending on certain cycle times may get in trouble.
But it is definitely worth a try.
from opener.
No. The solution is to use a bug free getmilliseconds(). Fundamentally, this is one implemented such that it not even see the change in the calendar time. You need to use a monotonically increasing function, devoid of influence from changes in calendar time. The rest of the logic is probably fine, I've kept it in my implementation.
from opener.
I like your solution. This would also solve the problem if the step change is negative due to time synchronization.
from opener.
I still do not see why multiple calls to manageConnections() (in a busy loop) is the right thing to do.
from opener.
unsigned GetMilliSeconds( void )
{
struct timespec now;
clock_gettime( CLOCK_MONOTONIC, &now );
unsigned msecs = ((unsigned)now.tv_nsec)/(1000*1000) + now.tv_sec * 1000;
return msecs;
}
Dick
from opener.
@swebb2066: the problem is that select may be blocked longer then the given time. As the manageConnections does internal some sums with expected cycle times the some can drift more and more away from the real time. This can lead to cases that timers are then much longer then they should be. The mulitple mangeConnection invocation does compensate this behavior.
from opener.
Why would multiple calls to m_pfTimeOutFunc and m_pfSendDataFunc from manageConnections() be the correct thing to do when cycle times drift?
Why would using the (bug free) elapsedtime to update timers in manageConnections() be worse than using the fixed constant OPENER_TIMER_TICK in manageConnections()?
from opener.
You are right when changing the interface to give manageConnections the elapsed time you don't need to multiple call manageConnections. Still you need the correct time function as presented above by @liftoff-sr
from opener.
@swebb2066 I am with you that your suggested fix should also be applied, but as I had troubles with negative time steps already in the original implementation, so a fix for that is also needed.
from opener.
To top most CMakeLists.txt, please add these two lines:
enable clock_gettime:
add_definitions( -D_POSIX_C_SOURCE=199309L )
in order for clock_gettime( CLOCK_MONOTONIC, &now ); to compile with the C language. (C++ does not need this.)
Then you may have to link to library "rt" additionally to provide that clock_gettime() function on linux.
from opener.
Putting the definition in the top most CMakeLists.txt would add the define also to the Windows build.
I added it to the POSIX specific CMake file, and applied your suggested fix to the GetMicroSeconds function. At least on my machine I didn't need the rt library.
from opener.
@swebb2066 I'm not sure, but this could also fix your issue as well, as CLOCK_MONOTONIC should not experience discontinuities due to NTP. (At least thats what I have interpreted from the description I found of CLOCK_MONOTONIC behavior)
But a fix for the Windows version is still missing.
from opener.
After digging into the topic if the Windows implementation also needs changes, I found out that the use performance counter is behaving monotonic.
So the Windows implementation does not need to change.
from opener.
Related Issues (20)
- Add Cipher Suites to EthernetIP Security object attributes 3 and 4
- Help with sample application. HOT 1
- Need help using shared libraries. HOT 2
- Need help connection points HOT 1
- InputOnlyConnectionPoint HOT 2
- Transport Class question HOT 1
- cipconnectionmanager.c does not compile with logs HOT 1
- Not configured for off-subnet multicast - Endianness mismatch? HOT 1
- How to use IP startup instead of network card name?
- OpENer/source/src/enet_encap /cpf.c line:247 HOT 3
- OpENer/source/src/cip /cipcommon.c link:1407 HOT 1
- New stable tag HOT 1
- Update Identity Object to Revision 2
- Failing Conformance Testing 20
- Upgrade of OpENer HOT 1
- Example Code HOT 1
- Multiple warnings on MVSC 2022
- QoS Object Behavior Test Error HOT 1
- Directions for generating documentation are wrong
- Question - implicit messaging
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opener.