Commit f96baae6 authored by Ludovic Apvrille's avatar Ludovic Apvrille

Revert "Merge branch 'MBED' into 'master'"

This reverts merge request !171
parent 424e484b

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

File deleted
......@@ -21,24 +21,8 @@ int my_clock_gettime(struct timespec *tp) {
#else
int clock_gettime(struct timespec *ts) {
//struct timeval tv;
//time(NULL);time since epoch in seconds
//people also use the variable localtime
//Dont understand the difference between this function and the other one
ts->tv_sec = time(NULL);
ts->tv_nsec = 0;
return 0;
}
int my_clock_gettime(struct timespec *tp) {
return clock_gettime(tp);
//this functions justs gives back the real time since epoch,
//is it the same as time()???
//return clock_gettime(CLOCK_REALTIME, tp);
//printf("Led1 encendido, led2 apagado, %d\n",seconds);
return clock_gettime(CLOCK_REALTIME, tp);
}
#endif
......@@ -118,11 +102,7 @@ void waitFor(long minDelay, long maxDelay) {
delayToTimeSpec(&tssrc, delay);
debugLong("............. waiting For", delay);
if(tssrc.tv_nsec > tsret.tv_nsec){
wait_us(tsret.tv_nsec/1000);
}else{
wait_us(tssrc.tv_nsec/1000);
}
nanosleep(&tssrc, &tsret);
debugLong("............. waiting Done for: ", delay);
}
......@@ -3,7 +3,6 @@
#include <time.h>
#include <sys/time.h>
#include "mbed.h"
......
objs = main.o HelloWorldReceiver.o HelloWorldGenerator.o
\ No newline at end of file
SRCS = generated_src/main.c generated_src/MeasurementDisplayer2.c generated_src/MeasurementDisplayer1.c generated_src/MeasurementGenerator.c
SRCS = generated_src/main.c generated_src/MeasurementDisplayer2.c generated_src/MeasurementDisplayer1.c generated_src/MeasurementGenerator.c
\ No newline at end of file
This diff is collapsed.
#include "message.h"
#include "asyncchannel.h"
#include "myerrors.h"
#include <mbed.h>
asyncchannel *getNewAsyncchannel(char *outname, char *inname, int isBlocking, int maxNbOfMessages) {
asyncchannel * asyncch = (asyncchannel *)(malloc(sizeof(struct asyncchannel)));
if (asyncch == NULL) {
criticalError("Allocation of asyncchannel failed");
}
asyncch->inname = inname;
asyncch->outname = outname;
asyncch->isBlocking = isBlocking;
asyncch->maxNbOfMessages = maxNbOfMessages;
return asyncch;
}
void destroyAsyncchannel(asyncchannel *asyncch) {
free(asyncch);
}
message* getAndRemoveOldestMessageFromAsyncChannel(asyncchannel *channel) {
message *msg;
message *previous;
if (channel->currentNbOfMessages == 0) {
return (message*)NULL;
}
if (channel->currentNbOfMessages == 1) {
channel->currentNbOfMessages = 0;
msg = channel->pendingMessages;
channel->pendingMessages = (message*)NULL;
return msg;
}
msg = channel->pendingMessages;
previous = msg;
while(msg->next != (message*)NULL) {
previous = msg;
msg = msg->next;
}
channel->currentNbOfMessages = channel->currentNbOfMessages -1;
previous->next = (message*)NULL;
return msg;
}
void addMessageToAsyncChannel(asyncchannel *channel, message *msg) {
msg->next = channel->pendingMessages;
channel->pendingMessages = msg;
channel->currentNbOfMessages = channel->currentNbOfMessages+1;
}
#ifndef ASYNCCHANNEL_H
#define ASYNCCHANNEL_H
struct asyncchannel;
#include "message.h"
#include "request.h"
struct asyncchannel {
char *outname;
char *inname;
int isBlocking; // In writing. Reading is always blocking
int maxNbOfMessages; //
struct request* outWaitQueue;
struct request* inWaitQueue;
message *pendingMessages;
int currentNbOfMessages;
};
typedef struct asyncchannel asyncchannel;
asyncchannel *getNewAsyncchannel(char *inname, char *outname, int isBlocking, int maxNbOfMessages);
void destroyAsyncchannel(asyncchannel *syncch);
message* getAndRemoveOldestMessageFromAsyncChannel(asyncchannel *channel);
void addMessageToAsyncChannel(asyncchannel *channel, message *msg);
#endif
//#include <stdlib.h>
//#include <stdio.h>
#include <time.h>
#define DEBUG_ON 1
#define DEBUG_OFF 2
//Serial pc(USBTX,USBRX);
#include <mbed.h>
#include "debug.h"
int _debug = DEBUG_OFF;
void activeDebug() {
_debug = DEBUG_ON;
printf("Modo debug activado");
}
void unactiveDebug() {
_debug = DEBUG_OFF;
printf("Modo debug desactivado");
}
void debugThreeInts(char *msg, int value1, int value2, int value3) {
if (_debug == DEBUG_OFF) {
return;
}
if (msg != NULL) {
printf("DT> %s: %d, %d, %d\n", msg, value1, value2, value3);
}
}
void debugTwoInts(char *msg, int value1, int value2) {
if (_debug == DEBUG_OFF) {
return;
}