Skip to content

Commit

Permalink
Fixed some erros for ECOS compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-bettencourt committed Dec 5, 2018
1 parent 20a4670 commit c1d49bc
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 54 deletions.
70 changes: 35 additions & 35 deletions ProjetoEcos/comando.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,39 +140,39 @@ void cmd_rc (int argc, char** argv)
+--------------------------------------------------------------------------*/
void cmd_sc (int argc, char** argv)
{
unsigned int n, i;
unsigned int n= 5, i;
unsigned char bufw[6];
unsigned char *bufr;

do{
bufw[0]=SOM;
bufw[1]=SCLK;
if ((n=argc) == 4) {
unsigned int x;
sscanf(argv[1], "%x", &x);
bufw[2]=(unsigned char)x;
sscanf(argv[2], "%x", &x);
bufw[3]=(unsigned char)x;
sscanf(argv[3], "%x", &x);
bufw[4]=(unsigned char)x;
}else{
bufw[0]=SOM;
bufw[1]=SCLK;
if ((n=argc) == 4) {
unsigned int x;
sscanf(argv[1], "%x", &x);
bufw[2]=(unsigned char)x;
sscanf(argv[2], "%x", &x);
bufw[3]=(unsigned char)x;
sscanf(argv[3], "%x", &x);
bufw[4]=(unsigned char)x;
}else{
cyg_mutex_lock(&cliblock);
printf("Wrong arguments for sc");
cyg_mutex_unlock(&cliblock);
return;
}
bufw[5]=EOM;

cyg_mbox_put( mbxSh, bufw );

cyg_mutex_lock(&cliblock);
printf("Wrong arguments for sc");
for (i=0; i<n; i++)
printf("buf[%d]=%x\n", i, bufw[i]);
cyg_mutex_unlock(&cliblock);
return;
}
bufw[5]=EOM;

cyg_mbox_put( mbxSh, bufw );

cyg_mutex_lock(&cliblock);
for (i=0; i<n; i++)
printf("buf[%d]=%x\n", i, bufw[i]);
cyg_mutex_unlock(&cliblock);

bufr = (unsigned char *)cyg_mbox_get(mbxRh);
//obter error message
}while(bufr[1]!=CMD_OK)

bufr = (unsigned char *)cyg_mbox_get(mbxRh);
//obter error message
}while(bufr[1]!=CMD_OK);

}

Expand Down Expand Up @@ -231,7 +231,7 @@ void cmd_rp (int argc, char** argv)
+--------------------------------------------------------------------------*/
void cmd_mmp (int argc, char** argv)
{
unsigned int n, i;
unsigned int n = 4, i;
unsigned char bufw[4];
unsigned char *bufr;

Expand Down Expand Up @@ -262,7 +262,7 @@ void cmd_mmp (int argc, char** argv)
+--------------------------------------------------------------------------*/
void cmd_mta (int argc, char** argv)
{
unsigned int n, i;
unsigned int n = 4, i;
unsigned char bufw[4];
unsigned char *bufr;

Expand Down Expand Up @@ -293,7 +293,7 @@ void cmd_mta (int argc, char** argv)
+--------------------------------------------------------------------------*/
void cmd_ra (int argc, char** argv)
{
unsigned int n, i;
unsigned int n = 3, i;
unsigned char bufw[3];
unsigned char *bufr;

Expand All @@ -316,7 +316,7 @@ void cmd_ra (int argc, char** argv)
+--------------------------------------------------------------------------*/
void cmd_dtl (int argc, char** argv)
{
unsigned int n, i;
unsigned int n = 5, i;
unsigned char bufw[5];
unsigned char *bufr;

Expand Down Expand Up @@ -349,7 +349,7 @@ void cmd_dtl (int argc, char** argv)
+--------------------------------------------------------------------------*/
void cmd_aa (int argc, char** argv)
{
unsigned int n, i;
unsigned int n = 3, i;
unsigned char bufw[4];
unsigned char *bufr;

Expand Down Expand Up @@ -380,7 +380,7 @@ void cmd_aa (int argc, char** argv)
+--------------------------------------------------------------------------*/
void cmd_rmm (int argc, char** argv)
{
unsigned int n, i;
unsigned int n= 3, i;
unsigned char bufw[3];
unsigned char *bufr;

Expand Down Expand Up @@ -409,7 +409,7 @@ void cmd_rmm (int argc, char** argv)
+--------------------------------------------------------------------------*/
void cmd_cmm (int argc, char** argv)
{
unsigned int n, i;
unsigned int n=3, i;
unsigned char bufw[3];
unsigned char *bufr;

Expand All @@ -432,7 +432,7 @@ void cmd_cmm (int argc, char** argv)
+--------------------------------------------------------------------------*/
void cmd_ir (int argc, char** argv)
{
unsigned int n, i;
unsigned int n=3, i;
unsigned char bufw[3];
unsigned char *bufr;

Expand Down
32 changes: 16 additions & 16 deletions ProjetoEcos/globalvariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ extern "C" {
}
#endif

#include <cyg/kernel/kapi.h>
#include <cyg/io/io.h>

#define SOM 0xFD /* start of message */
#define EOM 0xFE /* end of message */
#define RCLK 0xC0 /* read clock */
Expand All @@ -37,30 +40,27 @@ extern "C" {
#define CMD_ERROR 0xFF /* error in command */

//Variáveis globais de controlo
volatile int registerRequest = 0;
volatile int makeCalculations = 0;
volatile int LumThreshold = 2, TempThreshold = 30;
volatile int exitControl = 0;
volatile int p = 10;
extern volatile int registerRequest;
extern volatile int makeCalculations;
extern volatile int LumThreshold, TempThreshold;
extern volatile int exitControl;
extern volatile int p;

//Variáveis dos registos
volatile int iread = 0, iwrite = -1; nr = 0;
int NRBUF = 100;
volatile int registers[NRBUF][5];
extern volatile int iread, iwrite, nr;
extern int NRBUF;
extern volatile int registers[100][5];

/*error variable*/
volatile Cyg_ErrNo err;
volatile cyg_io_handle_t serH;

#include <cyg/kernel/kapi.h>
#include <cyg/io/io.h>
extern volatile Cyg_ErrNo err;
extern volatile cyg_io_handle_t serH;

/*Mail boxes handlers and objects for receiver and sender*/
cyg_handle_t mbxSh, mbxRh, mbxIPh, mbxPIh;
cyg_mbox mbxS, mbxR, mbxIP, mbxPI;
extern cyg_handle_t mbxSh, mbxRh, mbxIPh, mbxPIh;
extern cyg_mbox mbxS, mbxR, mbxIP, mbxPI;

/* and now a mutex to protect calls to the C library */
cyg_mutex_t cliblock;
extern cyg_mutex_t cliblock;

struct cloc_{
int hours;
Expand Down
Binary file removed ProjetoEcos/main
Binary file not shown.
Binary file removed ProjetoEcos/main.bin
Binary file not shown.
23 changes: 23 additions & 0 deletions ProjetoEcos/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@ extern void cmd_ini(int argc, char **argv);
extern void checkThresholds(int n);
extern int saveRegister(int registo[5]);

//Variáveis globais de controlo
volatile int registerRequest = 0;
volatile int makeCalculations = 0;
volatile int LumThreshold = 2, TempThreshold = 30;
volatile int exitControl = 0;
volatile int p = 10;

//Variáveis dos registos
volatile int iread = 0, iwrite = -1, nr = 0;
int NRBUF = 100;
volatile int registers[100][5];

/*error variable*/
volatile Cyg_ErrNo err;
volatile cyg_io_handle_t serH;

/*Mail boxes handlers and objects for receiver and sender*/
cyg_handle_t mbxSh, mbxRh, mbxIPh, mbxPIh;
cyg_mbox mbxS, mbxR, mbxIP, mbxPI;

/* and now a mutex to protect calls to the C library */
cyg_mutex_t cliblock;

/* we install our own startup routine which sets up threads */
void cyg_user_start(void)
{
Expand Down
6 changes: 3 additions & 3 deletions ProjetoEcos/processing.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <stdio.h>
#include <malloc.h>
#include "globalvariables.h"

int ** vector;
Expand All @@ -12,8 +11,9 @@ int date_calculator(cloc start, cloc end,cloc to_check);
void calc(cloc start_time,cloc end_time,int *results){
int maxL=0,minL=0,maxT=0,minT=0,mediaL=0,mediaT=0,values_to_mean=0;
cloc curr_sample_time=malloc(sizeof(cloc));

for (int i =0;i<nmbr_reg;i++){
int i = 0;

for (i =0;i<nmbr_reg;i++){
if(vector[i][6]!=0){//new entry
checker(&minL,&maxL,&minT,&maxT,vector[i]);
vector[i][6]=0;
Expand Down

0 comments on commit c1d49bc

Please sign in to comment.