From 535ff4d1583abb39cd5d76aaa3458489a2108dee Mon Sep 17 00:00:00 2001 From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr> Date: Mon, 13 Feb 2012 15:56:40 +0000 Subject: [PATCH] Resolved bug on random values for delay in generated CPOSIX code / AVATAR --- executablecode/Makefile.src | 2 +- executablecode/src/mytimelib.c | 5 ++++- executablecode/src/random.c | 7 ++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/executablecode/Makefile.src b/executablecode/Makefile.src index f005e67c8d..bdbdd4f06e 100755 --- a/executablecode/Makefile.src +++ b/executablecode/Makefile.src @@ -1 +1 @@ -SRCS = generated_src/main.c generated_src/TestBench.c generated_src/SpeedSensor.c generated_src/RadarSensor.c generated_src/GPSSensor.c generated_src/CarPositionSimulator.c generated_src/EmergencySimulator.c generated_src/Communication.c generated_src/DSRSC_Management.c generated_src/NeighbourhoodTableManagement.c generated_src/CorrectnessChecking.c generated_src/PTC.c generated_src/DrivingPowerReductionStrategy.c generated_src/BCU.c generated_src/DangerAvoidanceStrategy.c generated_src/BrakeManagement.c generated_src/CSCU.c generated_src/ObjectListManagement.c generated_src/PlausibilityCheck.c generated_src/VehiculeDynamicsManagement.c \ No newline at end of file +SRCS = generated_src/main.c generated_src/Block0.c generated_src/Block2.c generated_src/Block1.c \ No newline at end of file diff --git a/executablecode/src/mytimelib.c b/executablecode/src/mytimelib.c index 2282f5ac0b..d39c07ea85 100644 --- a/executablecode/src/mytimelib.c +++ b/executablecode/src/mytimelib.c @@ -90,8 +90,11 @@ void waitFor(long minDelay, long maxDelay) { struct timespec tsret; int delay; - debugMsg("Computing random"); + + debugMsg("Computing random delay"); + //debugLong("Min delay", minDelay); + //debugLong("Max delay", maxDelay); delay = computeLongRandom(minDelay, maxDelay); debugLong("Random delay=", delay); diff --git a/executablecode/src/random.c b/executablecode/src/random.c index 239d0891f1..b4bbddb19a 100644 --- a/executablecode/src/random.c +++ b/executablecode/src/random.c @@ -23,13 +23,14 @@ long computeLongRandom(long min, long max) { return min; } - long rand0 = (((long)(rand()))*powl(2, ((((sizeof(long)-2))*8)-1))); + + long rand0 = (long)rand(); long rand1 = rand0 % (max - min); //debugLong("min=", min); //debugLong("max=", max); //debugLong("rand0", rand0); - //debugLong("rand1", rand1); - debugLong("Random long", rand1 + min); + //debugLong("rand1", rand1); + //debugLong("Random long", rand1 + min); return rand1 + min; } -- GitLab