diff options
author | Brijeshcr | 2017-07-20 19:39:55 +0530 |
---|---|---|
committer | Brijeshcr | 2017-07-20 19:39:55 +0530 |
commit | 215a24b64f6d0ec3fcef06c2634926f730b3dcc5 (patch) | |
tree | 48072b76fe009ec8423ba9e179fef964db666a3a /2.3-1/src | |
parent | 9a2e3e3174a9ff35ba9b739cec4a0b8c052a8dbe (diff) | |
parent | dbf6486fa17d277729e0d6f77c2a6b93cbdd9424 (diff) | |
download | Scilab2C-215a24b64f6d0ec3fcef06c2634926f730b3dcc5.tar.gz Scilab2C-215a24b64f6d0ec3fcef06c2634926f730b3dcc5.tar.bz2 Scilab2C-215a24b64f6d0ec3fcef06c2634926f730b3dcc5.zip |
Added RPI demo and lcd128x64 fixed
Diffstat (limited to '2.3-1/src')
40 files changed, 1348 insertions, 1 deletions
diff --git a/2.3-1/src/c/auxiliaryFunctions/abs/zabss.c b/2.3-1/src/c/auxiliaryFunctions/abs/zabss.c index 4e7b4dd3..7ada57d1 100644 --- a/2.3-1/src/c/auxiliaryFunctions/abs/zabss.c +++ b/2.3-1/src/c/auxiliaryFunctions/abs/zabss.c @@ -16,6 +16,7 @@ #include "sqrt.h" #include "max.h" #include "min.h" +#include "doubleComplex.h" double zabss(doubleComplex in) { double real = dabss(zreals(in)); diff --git a/2.3-1/src/c/elementaryFunctions/includes/isvector.h b/2.3-1/src/c/elementaryFunctions/includes/isvector.h new file mode 100644 index 00000000..5f45abbe --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/includes/isvector.h @@ -0,0 +1,38 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#ifndef __ISVECTOR_H__ +#define __ISVECTOR_H__ + + +#include "types.h" +#include "doubleComplex.h" +#include "floatComplex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +char disvectora(double* , int); +char disvectors(double); +char sisvectora( float* , int); +char sisvectors( float); +char gisvectora(char* , int); +char gisvectors(char); +char zisvectora(doubleComplex*, int); +char zisvectors(doubleComplex); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/2.3-1/src/c/elementaryFunctions/interfaces/int_isvector.h b/2.3-1/src/c/elementaryFunctions/interfaces/int_isvector.h new file mode 100644 index 00000000..6d943bd3 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/interfaces/int_isvector.h @@ -0,0 +1,26 @@ + /*This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + + +#ifndef __INT_ISVECTOR_H__ +#define __INT_ISVECTOR_H__ + +#define d2isvectorg0(in, size ) disvectora(in, size[0]) +#define d0isvectorg0(in) disvectors(in) +#define s2isvectorg0(in , size) sisvectora(in, size[0]) +#define s0isvectorg0(in) sisvectors(in) +#define g2isvectorg0(in, size) gisvectora(in, size[0]) +#define g0isvectorg0(in) gisvectors(in) +#define z2isvectorg0(in, size) zisvectora(in , size[0]) +#define z0isvectorg0(in) zisvectors(in) + + +#endif diff --git a/2.3-1/src/c/elementaryFunctions/isvector/disvectora.c b/2.3-1/src/c/elementaryFunctions/isvector/disvectora.c new file mode 100644 index 00000000..3c41027f --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isvector/disvectora.c @@ -0,0 +1,23 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "isvector.h" +#include "types.h" +char disvectora(double* inp, int size1) +{ + if(size1 ==1) + return 'T'; + return 'F'; +} diff --git a/2.3-1/src/c/elementaryFunctions/isvector/disvectors.c b/2.3-1/src/c/elementaryFunctions/isvector/disvectors.c new file mode 100644 index 00000000..703e6673 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isvector/disvectors.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "isvector.h" +#include "types.h" + +char disvectors(double inp) +{ + double out='F'; + + return out; +} diff --git a/2.3-1/src/c/elementaryFunctions/isvector/gisvectora.c b/2.3-1/src/c/elementaryFunctions/isvector/gisvectora.c new file mode 100644 index 00000000..d2e261e9 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isvector/gisvectora.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "isvector.h" +#include "types.h" +#include "string.h" +char gisvectora(char *inp, int size1) +{ + if(size1 ==1) + return 'T'; + return 'F'; +} diff --git a/2.3-1/src/c/elementaryFunctions/isvector/gisvectors.c b/2.3-1/src/c/elementaryFunctions/isvector/gisvectors.c new file mode 100644 index 00000000..72118603 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isvector/gisvectors.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "isvector.h" +#include "types.h" + +char gisvectors(char inp) +{ + char out='F'; + + return out; +} diff --git a/2.3-1/src/c/elementaryFunctions/isvector/sisvectora.c b/2.3-1/src/c/elementaryFunctions/isvector/sisvectora.c new file mode 100644 index 00000000..09ad6515 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isvector/sisvectora.c @@ -0,0 +1,23 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "isvector.h" +#include "types.h" +char sisvectora(float* inp, int size1) +{ + if(size1 ==1) + return 'T'; + return 'F'; +} diff --git a/2.3-1/src/c/elementaryFunctions/isvector/sisvectors.c b/2.3-1/src/c/elementaryFunctions/isvector/sisvectors.c new file mode 100644 index 00000000..019bd464 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isvector/sisvectors.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "isvector.h" +#include "types.h" + +char sisvectors(float inp) +{ + char out='F'; + + return out; +} diff --git a/2.3-1/src/c/elementaryFunctions/isvector/zisvectora.c b/2.3-1/src/c/elementaryFunctions/isvector/zisvectora.c new file mode 100644 index 00000000..fba78124 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isvector/zisvectora.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "doubleComplex.h" +#include "isvector.h" +#include "types.h" + +char zisvectora(doubleComplex *inp, int size1) +{ + if(size1 ==1) + return 'T'; + return 'F'; +} diff --git a/2.3-1/src/c/elementaryFunctions/isvector/zisvectors.c b/2.3-1/src/c/elementaryFunctions/isvector/zisvectors.c new file mode 100644 index 00000000..bc9e5ce6 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isvector/zisvectors.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "isvector.h" +#include "types.h" +#include "doubleComplex.h" + +char zisvectors(doubleComplex inp) +{ + char out='F'; + + return out; +} diff --git a/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralLCD128x64.h b/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralLCD128x64.h index d541c9fd..93bdf279 100644 --- a/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralLCD128x64.h +++ b/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralLCD128x64.h @@ -22,13 +22,17 @@ extern "C" { int8 RPI_lcd128x64setup(void); void u8RPI_lcd128x64clears(uint8 colour); void u8RPI_lcd128x64Orientations(uint8 orientation); + void u8RPI_lcd128x64setOrigins(uint8 x, uint8 y); + void u8RPI_lcd128x64points(uint8 x, uint8 y, uint8 colour); void u8RPI_lcd128x64lineTos(uint8 x, uint8 y, uint8 colour); + void u8RPI_lcd128x64lines(uint8 x0, uint8 y0, uint8 x1, uint8 y1, uint8 colour); void u8RPI_lcd128x64circles(uint8 x, uint8 y, uint8 r, uint8 colour, uint8 filled); void u8RPI_lcd128x64putchars(uint8 x, uint8 y, uint8 c, uint8 bgCol, uint8 fgCol); void u8RPI_lcd128x64putss(uint8 x, uint8 y, char *str,int size, uint8 bgCol, uint8 fgCol); + void u8RPI_lcd128x64rectangles(uint8 x1, uint8 y1, uint8 x2, uint8 y2, uint8 colour, uint8 filled); void u8RPI_lcd128x64ellipses(uint8 cx, uint8 cy, uint8 xRadius, uint8 yRadius, uint8 colour, uint8 filled); diff --git a/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralLCD.h b/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralLCD.h index e6dcb7db..803f93e3 100644 --- a/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralLCD.h +++ b/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralLCD.h @@ -21,18 +21,22 @@ extern "C" { #endif #define u80u80u80u80u80u80u80u80u80u80RPI_lcdCharDef(fd,index,d0,d1,d2,d3,d4,d5,d6,d7) u8RPI_lcdCharDefs(fd,index,d0,d1,d2,d3,d4,d5,d6,d7); +#define u80d0d0d0d0d0d0d0d0d0RPI_lcdCharDef(fd,index,d0,d1,d2,d3,d4,d5,d6,d7) u8RPI_lcdCharDefs(fd,index,d0,d1,d2,d3,d4,d5,d6,d7); #define d0d0d0d0d0d0d0d0d0d0RPI_lcdCharDef(fd,index,d0,d1,d2,d3,d4,d5,d6,d7) u8RPI_lcdCharDefs(fd,index,d0,d1,d2,d3,d4,d5,d6,d7); #define u80RPI_lcdClear(fd) u8RPI_lcdClears(fd); #define d0RPI_lcdClear(fd) u8RPI_lcdClears(fd); #define u80u80RPI_lcdCursorBlink(fd,state) u8RPI_lcdCursorBlinks(fd,state); +#define u80d0RPI_lcdCursorBlink(fd,state) u8RPI_lcdCursorBlinks(fd,state); #define d0d0RPI_lcdCursorBlink(fd,state) u8RPI_lcdCursorBlinks(fd,state); #define u80u80RPI_lcdCursor(fd,state) u8RPI_lcdCursors(fd,state); +#define u80d0RPI_lcdCursor(fd,state) u8RPI_lcdCursors(fd,state); #define d0d0RPI_lcdCursor(fd,state) u8RPI_lcdCursors(fd,state); #define u80u80RPI_lcdDisplay(fd,state) u8RPI_lcdDisplays(fd,state); +#define u80d0RPI_lcdDisplay(fd,state) u8RPI_lcdDisplays(fd,state); #define d0d0RPI_lcdDisplay(fd,state) u8RPI_lcdDisplays(fd,state); #define u80RPI_lcdHome(fd) u8RPI_lcdHomes(fd); @@ -42,12 +46,15 @@ extern "C" { #define d0d0d0d0d0d0d0d0d0d0d0d0d0RPI_lcdIniti80(rows,cols,bits,rs,strb,d0,d1,d2,d3,d4,d5,d6,d7) u8RPI_lcdInits(rows,cols,bits,rs,strb,d0,d1,d2,d3,d4,d5,d6,d7); #define u80u80u80RPI_lcdPosition(fd,row,col) u8RPI_lcdPositions(fd,row,col); +#define u80d0d0RPI_lcdPosition(fd,row,col) u8RPI_lcdPositions(fd,row,col); #define d0d0d0RPI_lcdPosition(fd,row,col) u8RPI_lcdPositions(fd,row,col); #define u80u80RPI_lcdPutchar(fd,char) u8RPI_lcdPutchars(fd,char); +#define u80d0RPI_lcdPutchar(fd,char) u8RPI_lcdPutchars(fd,char); #define d0d0RPI_lcdPutchar(fd,char) u8RPI_lcdPutchars(fd,char); #define u80u80RPI_lcdSendCommand(fd,cmd) u8RPI_lcdSendCommands(fd,cmd); +#define u80d0RPI_lcdSendCommand(fd,cmd) u8RPI_lcdSendCommands(fd,cmd); #define d0d0RPI_lcdSendCommand(fd,cmd) u8RPI_lcdSendCommands(fd,cmd); #define u80g2RPI_lcdPuts(fd,msg,size) u8RPI_lcdPutss(fd,msg,size[1]);; diff --git a/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralLCD128x64.h b/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralLCD128x64.h index 77cc433c..8bb4b17e 100644 --- a/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralLCD128x64.h +++ b/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralLCD128x64.h @@ -33,6 +33,7 @@ extern "C" { #define u80u80u80RPI_lcd128x64point(x,y,colour) u8RPI_lcd128x64points(x,y,colour); #define d0d0d0RPI_lcd128x64point(x,y,colour) u8RPI_lcd128x64points(x,y,colour); + #define u80u80u80RPI_lcd128x64lineTo(x,y,colour) u8RPI_lcd128x64lineTos(x,y,colour); #define d0d0d0RPI_lcd128x64lineTo(x,y,colour) u8RPI_lcd128x64lineTos(x,y,colour); diff --git a/2.3-1/src/c/matrixOperations/includes/matrix.h b/2.3-1/src/c/matrixOperations/includes/matrix.h index dbb0e223..582fd221 100644 --- a/2.3-1/src/c/matrixOperations/includes/matrix.h +++ b/2.3-1/src/c/matrixOperations/includes/matrix.h @@ -16,6 +16,8 @@ #include "types.h" #include "doubleComplex.h" +#include "uint16.h" + #ifdef __cplusplus extern "C" { diff --git a/2.3-1/src/c/matrixOperations/includes/nnz.h b/2.3-1/src/c/matrixOperations/includes/nnz.h new file mode 100644 index 00000000..c7d2d491 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/includes/nnz.h @@ -0,0 +1,37 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#ifndef __NNZ_H__ +#define __NNZ_H__ + +#include "types.h" +#include "doubleComplex.h" +#include "uint16.h" + +#ifdef __cplusplus +extern "C" { +#endif + +uint16 dnnza(double* , int , int); +uint16 dnnzs(double); +uint16 snnza( float* , int , int); +uint16 snnzs( float); +uint16 znnza(doubleComplex *, int , int); +uint16 znnzs(doubleComplex); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__NNZ_H__*/ diff --git a/2.3-1/src/c/matrixOperations/interfaces/int_matrix.h b/2.3-1/src/c/matrixOperations/interfaces/int_matrix.h index f69ba116..5935f4a3 100644 --- a/2.3-1/src/c/matrixOperations/interfaces/int_matrix.h +++ b/2.3-1/src/c/matrixOperations/interfaces/int_matrix.h @@ -46,4 +46,4 @@ extern "C" { } /* extern "C" */ #endif -#endif /*__INT_CUMSUM_H__*/ +#endif /*__INT_MATRIX_H__*/ diff --git a/2.3-1/src/c/matrixOperations/interfaces/int_nnz.h b/2.3-1/src/c/matrixOperations/interfaces/int_nnz.h new file mode 100644 index 00000000..0ef39536 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/interfaces/int_nnz.h @@ -0,0 +1,35 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#ifndef __INT_NNZ_H__ +#define __INT_NNZ_H__ + + +#ifdef __cplusplus +extern "C" { +#endif + +#define d2nnzu160(in1, size) dnnza(in1, size[0], size[1]) +#define d0nnzu160(in) dnnzs(in) + +#define s2nnzu160(in1, size) snnza(in1, size[0], size[1]) +#define s0nnzu160(in) snnzs(in) + +#define z2nnzu160(in1, size) znnza(in1, size[0], size[1]) +#define z0nnzu160(in) znnzs(in) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_NNZ_H__*/ diff --git a/2.3-1/src/c/matrixOperations/nnz/dnnza.c b/2.3-1/src/c/matrixOperations/nnz/dnnza.c new file mode 100644 index 00000000..b4d40bd8 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/nnz/dnnza.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +/*Function returns cumulative sum of members of array/matrix*/ + +#include "nnz.h" +#include "types.h" +#include "uint16.h" + +uint16 dnnza(double *in, int irow, int icolumn) +{ + int i; + uint16 final=0; + for(i=0; i< irow*icolumn ; i++) + { + if( in[i] != 0) + { + final++; + + } + + } +return final; +} diff --git a/2.3-1/src/c/matrixOperations/nnz/dnnzs.c b/2.3-1/src/c/matrixOperations/nnz/dnnzs.c new file mode 100644 index 00000000..c878d331 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/nnz/dnnzs.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +/*Function returns cumulative sum of members of array/matrix*/ + +#include "nnz.h" +#include "types.h" +#include "uint16.h" + +uint16 dnnzs(double in) +{ + if(in !=0) + return 1; + else + return 0; +} diff --git a/2.3-1/src/c/matrixOperations/nnz/snnza.c b/2.3-1/src/c/matrixOperations/nnz/snnza.c new file mode 100644 index 00000000..df27f0fe --- /dev/null +++ b/2.3-1/src/c/matrixOperations/nnz/snnza.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +/*Function returns cumulative sum of members of array/matrix*/ + +#include "nnz.h" +#include "types.h" +#include "uint16.h" + +uint16 snnza(float*in, int irow, int icolumn) +{ + int i; + uint16 final=0; + for(i=0; i< irow*icolumn ; i++) + { + if( in[i] != 0) + { + final++; + + } + + } +return final; +} diff --git a/2.3-1/src/c/matrixOperations/nnz/snnzs.c b/2.3-1/src/c/matrixOperations/nnz/snnzs.c new file mode 100644 index 00000000..674d4fac --- /dev/null +++ b/2.3-1/src/c/matrixOperations/nnz/snnzs.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +/*Function returns cumulative sum of members of array/matrix*/ + +#include "nnz.h" +#include "types.h" +#include "uint16.h" + +uint16 snnzs(float in) +{ + if(in !=0) + return 1; + else + return 0; +} diff --git a/2.3-1/src/c/matrixOperations/nnz/znnza.c b/2.3-1/src/c/matrixOperations/nnz/znnza.c new file mode 100644 index 00000000..3b913e8b --- /dev/null +++ b/2.3-1/src/c/matrixOperations/nnz/znnza.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +/*Function returns cumulative sum of members of array/matrix*/ + +#include "nnz.h" +#include "types.h" +#include "uint16.h" +#include "doubleComplex.h" +uint16 znnza(doubleComplex* in, int irow, int icolumn) +{ + int i; + uint16 final=0; + for(i=0; i< irow*icolumn ; i++) + { + if(( zreals(in[i]) !=0 )||( zimags(in[i])!=0)) + { + final++; + + } + + } +return final; +} diff --git a/2.3-1/src/c/matrixOperations/nnz/znnzs.c b/2.3-1/src/c/matrixOperations/nnz/znnzs.c new file mode 100644 index 00000000..2907afcf --- /dev/null +++ b/2.3-1/src/c/matrixOperations/nnz/znnzs.c @@ -0,0 +1,26 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +/*Function returns cumulative sum of members of array/matrix*/ + +#include "nnz.h" +#include "types.h" +#include "uint16.h" +#include "doubleComplex.h" + +uint16 znnzs(doubleComplex in) +{ + if((zreals(in)== 0 ) && (zimags(in)==0)) + return 0; + else + return 1; +} diff --git a/2.3-1/src/c/operations/addition/zadds.c b/2.3-1/src/c/operations/addition/zadds.c index d4a94dc5..768faf38 100644 --- a/2.3-1/src/c/operations/addition/zadds.c +++ b/2.3-1/src/c/operations/addition/zadds.c @@ -11,6 +11,7 @@ */ #include "addition.h" +#include "doubleComplex.h" doubleComplex zadds(doubleComplex z1, doubleComplex z2) { return DoubleComplex(zreals(z1) + zreals(z2), diff --git a/2.3-1/src/c/statisticsFunctions/includes/median.h b/2.3-1/src/c/statisticsFunctions/includes/median.h new file mode 100644 index 00000000..accb5df0 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/includes/median.h @@ -0,0 +1,46 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#ifndef __MEDIAN_H__ +#define __MEDIAN_H__ + +#include "types.h" +#include "doubleComplex.h" +#include "uint16.h" + +#ifdef __cplusplus +extern "C" { +#endif + +double dmediana(double* , int ); +void dmedianrowa(double*, int, int, double*); +void dmediancola(double*, int, int, double*); + +float smediana(float* , int ); +void smedianrowa(float*, int, int, float*); +void smediancola(float*, int, int, float*); + +uint16 u16mediana(uint16* , int ); +void u16medianrowa(uint16*, int, int, uint16*); +void u16mediancola(uint16*, int, int, uint16*); + +doubleComplex zmediana(doubleComplex* , int ); +void zmedianrowa(doubleComplex*, int, int, doubleComplex*); +void zmediancola(doubleComplex*, int, int, doubleComplex*); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__MATRIX_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/interfaces/int_median.h b/2.3-1/src/c/statisticsFunctions/interfaces/int_median.h new file mode 100644 index 00000000..2a219870 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/interfaces/int_median.h @@ -0,0 +1,57 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#ifndef __INT_MEDIAN_H__ +#define __INT_MEDIAN_H__ + + +#ifdef __cplusplus +extern "C" { +#endif + +#define d2mediand0(in1, size) dmediana(in1, size[0]* size[1]) +#define d2g2mediand2(in1, size1, in2, size2, out) (in2[0]== 'r') ? dmedianrowa(in1, size1[0], size1[1], out) :dmediancola(in1, size1[0], size1[1], out) + +#define s2medians0(in1, size) smediana(in1, size[0]* size[1]) +#define s2g2medians2(in1, size1, in2, size2, out) (in2[0]== 'r') ? smedianrowa(in1, size1[0], size1[1], out) :smediancola(in1, size1[0], size1[1], out) + +#define u162medianu160(in1, size) u16mediana(in1, size[0]* size[1]) +#define u162g2medianu162(in1, size1, in2, size2, out) (in2[0]== 'r') ? u16medianrowa(in1, size1[0], size1[1], out) :u16mediancola(in1, size1[0], size1[1], out) + +#define z2medianz0(in1, size) zmediana(in1, size[0]* size[1]) +#define z2g2medianz2(in1, size1, in2, size2, out) (in2[0]== 'r') ? zmedianrowa(in1, size1[0], size1[1], out) :zmediancola(in1, size1[0], size1[1], out) + + +#define s2d0d0matrixs2(in1, size, in2, in3, out ) smatrixa(in1, size[0], size[1], in2, in3, out) +#define s2s0s0matrixs2(in1, size, in2, in3, out ) smatrixa(in1, size[0], size[1], in2, in3, out) +//#define s2u160u160matrixs2(in1, size, in2, in3, out ) smatrixa(in1, size[0], size[1], in2, in3, out) +//#define s2u80u80matrixs2(in1, size, in2, in3, out ) smatrixa(in1, size[0], size[1], in2, in3, out) + +#define u162d0d0matrixu162(in1, size, in2, in3, out ) u16matrixa(in1, size[0], size[1], in2, in3, out) +#define u162s0s0matrixu162(in1, size, in2, in3, out ) u16matrixa(in1, size[0], size[1], in2, in3, out) +//#define s2u160u160matrixs2(in1, size, in2, in3, out ) smatrixa(in1, size[0], size[1], in2, in3, out) +//#define s2u80u80matrixs2(in1, size, in2, in3, out ) smatrixa(in1, size[0], size[1], in2, in3, out) + +#define z2d0d0matrixz2(in1, size, in2, in3, out ) zmatrixa(in1, size[0], size[1], in2, in3, out) +#define z2s0s0matrixz2(in1, size, in2, in3, out ) zmatrixa(in1, size[0], size[1], in2, in3, out) +//#define s2u160u160matrixs2(in1, size, in2, in3, out ) smatrixa(in1, size[0], size[1], in2, in3, out) +//#define s2u80u80matrixs2(in1, size, in2, in3, out ) smatrixa(in1, size[0], size[1], in2, in3, out) + + + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_MATRIX_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/median/dmediana.c b/2.3-1/src/c/statisticsFunctions/median/dmediana.c new file mode 100644 index 00000000..cb2463c5 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/median/dmediana.c @@ -0,0 +1,58 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "median.h" +#include "types.h" +#include "uint16.h" + +double dmediana(double *in, int size) +{ + double a; double fin; + + + for (int i = 0; i < size; ++i) + + { + + for (int j = i + 1; j < size; ++j) + + { + + if (in[i] > in[j]) + + { + + a = in[i]; + + in[i] = in[j]; + + in[j] = a; + + } + + } + + } + + + if(size%2 ==0) + { + fin= (in[size/2]+ in[(size/2)-1])/2; + } + else + { + fin= in[(size-1)/2]; + } + + return fin; +} diff --git a/2.3-1/src/c/statisticsFunctions/median/dmediancola.c b/2.3-1/src/c/statisticsFunctions/median/dmediancola.c new file mode 100644 index 00000000..b3ff4fb8 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/median/dmediancola.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "median.h" +#include "types.h" +#include "uint16.h" + +void dmediancola(double *in, int row, int col, double* out) +{ + double inter[col]; + + +for(int i=0; i< row; i++) + { + for(int j=0 ; j< col; j++) + { + inter[j]= in[i+ (j*row)]; + + } + out[i]= dmediana( inter, col); + + } + + +} diff --git a/2.3-1/src/c/statisticsFunctions/median/dmedianrowa.c b/2.3-1/src/c/statisticsFunctions/median/dmedianrowa.c new file mode 100644 index 00000000..4b5879c5 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/median/dmedianrowa.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "median.h" +#include "types.h" +#include "uint16.h" + +void dmedianrowa(double *in, int row, int col, double* out) +{ + double inter[row]; + + + +for(int i=0; i< col; i++) + { + for(int j=0 ; j< row; j++) + { + inter[j]= in[j+ (i*row)]; + + } + out[i]= dmediana( inter, row); + + } + + +} diff --git a/2.3-1/src/c/statisticsFunctions/median/smediana.c b/2.3-1/src/c/statisticsFunctions/median/smediana.c new file mode 100644 index 00000000..9e86b77e --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/median/smediana.c @@ -0,0 +1,57 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "median.h" +#include "types.h" +#include "uint16.h" + +float smediana(float *in, int size) +{ + float a; float fin; + + + for (int i = 0; i < size; ++i) + + { + + for (int j = i + 1; j < size; ++j) + + { + + if (in[i] > in[j]) + + { + + a = in[i]; + + in[i] = in[j]; + + in[j] = a; + + } + + } + + } + + if(size%2 ==0) + { + fin= (in[size/2]+ in[(size/2)-1])/2; + } + else + { + fin= in[(size-1)/2]; + } + + return fin; +} diff --git a/2.3-1/src/c/statisticsFunctions/median/smediancola.c b/2.3-1/src/c/statisticsFunctions/median/smediancola.c new file mode 100644 index 00000000..2fc4eaf1 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/median/smediancola.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "median.h" +#include "types.h" +#include "uint16.h" + +void smediancola(float *in, int row, int col, float* out) +{ + float inter[col]; + + +for(int i=0; i< row; i++) + { + for(int j=0 ; j< col; j++) + { + inter[j]= in[i+ (j*row)]; + + } + out[i]= smediana( inter, col); + + } + + +} diff --git a/2.3-1/src/c/statisticsFunctions/median/smedianrowa.c b/2.3-1/src/c/statisticsFunctions/median/smedianrowa.c new file mode 100644 index 00000000..aab59382 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/median/smedianrowa.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "median.h" +#include "types.h" +#include "uint16.h" + +void smedianrowa(float *in, int row, int col, float* out) +{ + float inter[row]; + + + +for(int i=0; i< col; i++) + { + for(int j=0 ; j< row; j++) + { + inter[j]= in[j+ (i*row)]; + + } + out[i]= smediana( inter, row); + + } + + +} diff --git a/2.3-1/src/c/statisticsFunctions/median/u16mediana.c b/2.3-1/src/c/statisticsFunctions/median/u16mediana.c new file mode 100644 index 00000000..b45c5302 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/median/u16mediana.c @@ -0,0 +1,57 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "median.h" +#include "types.h" +#include "uint16.h" + +uint16 u16mediana(uint16 *in, int size) +{ + uint16 a; uint16 fin; + + + for (int i = 0; i < size; ++i) + + { + + for (int j = i + 1; j < size; ++j) + + { + + if (in[i] > in[j]) + + { + + a = in[i]; + + in[i] = in[j]; + + in[j] = a; + + } + + } + + } + + if(size%2 ==0) + { + fin= (in[size/2]+ in[(size/2)-1])/2; + } + else + { + fin= in[(size-1)/2]; + } + + return fin; +} diff --git a/2.3-1/src/c/statisticsFunctions/median/u16mediancola.c b/2.3-1/src/c/statisticsFunctions/median/u16mediancola.c new file mode 100644 index 00000000..77952a35 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/median/u16mediancola.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "median.h" +#include "types.h" +#include "uint16.h" + +void u16mediancola(uint16 *in, int row, int col, uint16* out) +{ + uint16 inter[col]; + + +for(int i=0; i< row; i++) + { + for(int j=0 ; j< col; j++) + { + inter[j]= in[i+ (j*row)]; + + } + out[i]= u16mediana( inter, col); + + } + + +} diff --git a/2.3-1/src/c/statisticsFunctions/median/u16medianrowa.c b/2.3-1/src/c/statisticsFunctions/median/u16medianrowa.c new file mode 100644 index 00000000..8e5b98ef --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/median/u16medianrowa.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "median.h" +#include "types.h" +#include "uint16.h" + +void u16medianrowa(uint16 *in, int row, int col, uint16* out) +{ + uint16 inter[row]; + + + +for(int i=0; i< col; i++) + { + for(int j=0 ; j< row; j++) + { + inter[j]= in[j+ (i*row)]; + + } + out[i]= u16mediana( inter, row); + + } + + +} diff --git a/2.3-1/src/c/statisticsFunctions/median/zmediana.c b/2.3-1/src/c/statisticsFunctions/median/zmediana.c new file mode 100644 index 00000000..32726e77 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/median/zmediana.c @@ -0,0 +1,64 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "median.h" +#include "types.h" +#include "uint16.h" +#include "doubleComplex.h" +#include "addition.h" +#include "division.h" +#include "abs.h" + +doubleComplex zmediana(doubleComplex *in, int size) +{ + doubleComplex a; doubleComplex fin; doubleComplex middle; + + + for (int i = 0; i < size; ++i) + + { + + for (int j = i + 1; j < size; ++j) + + { + + if (zabss(in[i]) > zabss(in[j])) + + { + + a = in[i]; + + in[i] = in[j]; + + in[j] = a; + + } + + } + + } + + + + if(size%2 ==0) + { + middle= zadds(in[size/2], in[(size/2)-1]); + fin= zrdivs(middle, DoubleComplex(2,0)); + } + else + { + fin= in[(size-1)/2]; + } + + return fin; +} diff --git a/2.3-1/src/c/statisticsFunctions/median/zmediancola.c b/2.3-1/src/c/statisticsFunctions/median/zmediancola.c new file mode 100644 index 00000000..d709d98b --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/median/zmediancola.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "median.h" +#include "types.h" +#include "uint16.h" +#include "doubleComplex.h" + +void zmediancola(doubleComplex *in, int row, int col, doubleComplex * out) +{ + doubleComplex inter[col]; + + +for(int i=0; i< row; i++) + { + for(int j=0 ; j< col; j++) + { + inter[j]= in[i+ (j*row)]; + + } + out[i]= zmediana( inter, col); + + } + + +} diff --git a/2.3-1/src/c/statisticsFunctions/median/zmedianrowa.c b/2.3-1/src/c/statisticsFunctions/median/zmedianrowa.c new file mode 100644 index 00000000..ab2e0d4a --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/median/zmedianrowa.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + + +#include "median.h" +#include "types.h" +#include "uint16.h" +#include "doubleComplex.h" + +void zmedianrowa(doubleComplex *in, int row, int col, doubleComplex* out) +{ + doubleComplex inter[row]; + + + +for(int i=0; i< col; i++) + { + for(int j=0 ; j< row; j++) + { + inter[j]= in[j+ (i*row)]; + + } + out[i]= zmediana( inter, row); + + } + + +} diff --git a/2.3-1/src/python/serverWP.py b/2.3-1/src/python/serverWP.py new file mode 100755 index 00000000..c41c25f1 --- /dev/null +++ b/2.3-1/src/python/serverWP.py @@ -0,0 +1,203 @@ +import wiringpi as wp +import socket +import subprocess as sp +import logging +import traceback +import sys +import RPi.GPIO as GPIO + +logging.basicConfig(filename='log.txt',level=logging.DEBUG) +logger=logging.getLogger(__name__) +pinNum=0 +#wp.wiringPiSetup() +GPIO.setmode(GPIO.BCM) + +commands={ +'cls':'s.close()\n\ta="Connection Closed"\n\tgo=0', +'i2c':'if sys.version_info<(3,0):\n\t\ta=sp.check_output(inputList[0].split())\n\telse:\n\t\ta=sp.run(inputList[0].split(),stdout=sp.PIPE).stdout.decode("utf-8")', +'anR':'a=wp.analogRead(int(inputList[0]))', +'anW':'a=wp.analogWrite(int(inputList[0]),int(inputList[1]))', +'bRv':'a=wp.piBoardRev()', +'BtR':'a=wp.digitalReadByte()', +'BtW':'a=wp.digitalWriteByte(int(inputList[0]))', +'CR1':'a=wp.wiringPiI2CRead(int(inputList[0]))', +'CR2':'a=wp.wiringPiI2CReadReg8(int(inputList[0]),int(inputList[1]))', +'CR3':'a=wp.wiringPiI2CReadReg16(int(inputList[0]),int(inputList[1]))', +'CSe':'a=wp.wiringPiI2CSetup(int(inputList[0]))', +'CSI':'a=wp.wiringPiI2CSetupInterface(inputList[0],int(inputList[1]))', +'CW1':'a=wp.wiringPiI2CWrite(int(inputList[0]),int(inputList[1]))', +'CW2':'a=wp.wiringPiI2CWriteReg8(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'CW3':'a=wp.wiringPiI2CWriteReg16(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'deS':'a=wp.delay(int(inputList[0]))', +'deU':'a=wp.delayMicroseconds(int(inputList[0]))', +'diR':'a=wp.digitalRead(int(inputList[0]))', +'diW':'a=wp.digitalWrite(int(inputList[0]),int(inputList[1]))', +'dsS':'a=wp.ds1302Setup(int(inputList[0]),int(inputList[1]),int(inputList[2]),)', +'dsR':'a=wp.ds1302rtcRead(int(inputList[0]))', +'dsW':'a=wp.ds1302rtcWrite(int(inputList[0]),int(inputList[1]))', +'dsr':'a=wp.ds1302ramRead(int(inputList[0]))', +'dsw':'a=wp.ds1302ramWrite(int(inputList[0]),int(inputList[1]))', +'dsc':'a=wp.ds1302clockRead(int(inputList[0]))', +'dsC':'a=wp.ds1302clockWrite(int(inputList[0]))', +'dst':'a=wp.ds1302trickleCharge(int(inputList[0]),int(inputList[1]))', +'gAS':'a=wp.gertboardAnalogSetup(int(inputList[0]))', +'gAR':'a=wp.gertboardAnalogRead(int(inputList[0]))', +'gAt':'a=wp.getAlt(int(inputList[0]))', +'gAW':'a=wp.gertboardAnalogWrite(int(inputList[0]),int(inputList[1]))', +'gSS':'a=wp.gertboardSPISetup()', +'Int':'if pinNum==1:\n\t\tpin=wp.wpiPinToGpio(int(inputList[0]))\n\telif pinNum==2:\n\t\tpin=int(inputList[0])\n\telif pinNum==3:\n\t\tpin=wp.physPinToGpio(int(inputList[0]))\n\tGPIO.setup(pin,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)\n\tif int(inputList[1])==-1:\n\t\ta=GPIO.wait_for_edge(pin,GPIO.RISING)\n\telse:\n\t\ta=GPIO.wait_for_edge(pin,GPIO.RISING,timeout=int(inputList[1]))\n\tif type(a)==int:\n\t\ta=1\n\telse:\n\t\ta=0', +#'a=wp.waitForInterrupt(int(inputList[0]),int(inputList[1]))', +#'ISR':'a=wp.wiringPiISR(int(inputList[0]),int(inputList[1]),inputList[2])', +'lCB':'a=wp.lcdCursorBlink(int(inputList[0]),int(inputList[1]))', +'lCD':'a=wp.lcdCharDef(int(inputList[0]),int(inputList[1]),[int(inputList[2]),int(inputList[3]),int(inputList[4]),int(inputList[5]),int(inputList[6]),int(inputList[7]),int(inputList[8]),int(inputList[9])])', +'lCl':'a=wp.lcdClear(int(inputList[0]))', +'lCu':'a=wp.lcdCursor(int(inputList[0]),int(inputList[1]))', +'lDs':'a=wp.lcdDisplay(int(inputList[0]),int(inputList[1]))', +'lHo':'a=wp.lcdHome(int(inputList[0]))', +'lIn':'a=wp.lcdInit(int(inputList[0]),int(inputList[1]),int(inputList[2]),int(inputList[3]),int(inputList[4]),int(inputList[5]),int(inputList[6]),int(inputList[7]),int(inputList[8]),int(inputList[9]),int(inputList[10]),int(inputList[11]),int(inputList[12]))', +'lok':'a=wp.piLock(int(inputList[0]))', +'lPc':'a=wp.lcdPutchar(int(inputList[0]),int(inputList[1]))', +'lPo':'a=wp.lcdPosition(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'lPf':'a=wp.lcdPrintf(int(inputList[0]),inputList[1])', +'lPu':'a=wp.lcdPuts(int(inputList[0]),inputList[1])', +'lSC':'a=wp.lcdSendCommand(int(inputList[0]),inputList[1])', +'Lse':'a=wp.lcd128x64setup()', +'Lup':'a=wp.lcd128x64update()', +'LOr':'a=wp.lcd128x64setOrigin(int(inputList[0]),int(inputList[1]))', +'LOn':'a=wp.lcd128x64setOrientation(int(inputList[0]))', +#'LCo':'a=wp.lcd128x64orientCoord(int(inputList[0]),int(inputList[1]))', +#'LSS':'a=wp.lcd128x64ScreenSize(int(inputList[0]),int(inputList[1]))', +'Lpo':'a=wp.lcd128x64point(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'Lli':'a=wp.lcd128x64line(int(inputList[0]),int(inputList[1]),int(inputList[2]),int(inputList[3]),int(inputList[4]))', +'LlT':'a=wp.lcd128x64lineTo(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'Lre':'a=wp.lcd128x64rectangle(int(inputList[0]),int(inputList[1]),int(inputList[2]),int(inputList[3]),int(inputList[4]),int(inputList[5]))', +'Lci':'a=wp.lcd128x64circle(int(inputList[0]),int(inputList[1]),int(inputList[2]),int(inputList[0]),int(inputList[3]),int(inputList[4]))', +'Lel':'a=wp.lcd128x64ellipse(int(inputList[0]),int(inputList[1]),int(inputList[2]),int(inputList[3]),int(inputList[4]),int(inputList[5]))', +'Lpc':'a=wp.lcd128x64putchar(int(inputList[0]),int(inputList[1]),int(inputList[2]),int(inputList[3]),int(inputList[4]),int(inputList[5]))', +'LPu':'a=wp.lcd128x64puts(int(inputList[0]),int(inputList[1]),inputList[2],int(inputList[3]),int(inputList[4]))', +'LCl':'a=wp.lcd128x64clear(int(inputList[0]))', +'mic':'a=wp.micros()', +'mil':'a=wp.millis()', +'mp6':'a=wp.mcp23016Setup(int(inputList[0]),int(inputList[1]))', +'mp7':'a=wp.mcp23017Setup(int(inputList[0]),int(inputList[1]))', +'mp8':'a=wp.mcp23008Setup(int(inputList[0]),int(inputList[1]))', +#'mp2':'a=wp.mcp3002Setup(int(inputList[0]),int(inputList[1]))', +#'mp4':'a=wp.mcp3004Setup(int(inputList[0]),int(inputList[1]))', +#'mp3':'a=wp.mcp3422Setup(int(inputList[0]),int(inputList[1]),int(inputList[2]),int(inputList[3]))', +#'mp0':'a=wp.mcp4802Setup(int(inputList[0]),int(inputList[1]))', +'ms7':'a=wp.mcp23s17Setup(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'ms8':'a=wp.mcp23s08Setup(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'mxR':'a=wp.maxDetectRead(int(inputList[0]),inputList[1])', +'mx3':'a=wp.max31855Setup(int(inputList[0]),int(inputList[1]))', +'mx5':'a=wp.max5322Setup(int(inputList[0]),int(inputList[1]))', +'NES':'a=wp.setupNesJoystick(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'NER':'a=wp.readNesJoystick(int(inputList[0]))', +'pDr':'a=wp.setPadDrive(int(inputList[0]),int(inputList[1]))', +'pf7':'a=wp.pcf8574Setup(int(inputList[0]),int(inputList[1]))', +'pf9':'a=wp.pcf8591Setup(int(inputList[0]),int(inputList[1]))', +'pG1':'a=wp.piGlow1(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'pGL':'a=wp.piGlowLeg(int(inputList[0]),int(inputList[1]))', +'pGR':'a=wp.piGlowRing(int(inputList[0]),int(inputList[1]))', +'pGS':'a=wp.piGlowSetup(int(inputList[0]))', +'PhS':'a=wp.scrollPhatSetup()', +'PhU':'a=wp.scrollPhatUpdate()', +'PhC':'a=wp.scrollPhatClear()', +'Php':'a=wp.scrollPhatPoint(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'PhL':'a=wp.scrollPhatLine(int(inputList[0]),int(inputList[1]),int(inputList[2]),int(inputList[3]),int(inputList[4]))', +'PhT':'a=wp.scrollPhatLineTo(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'PhR':'a=wp.scrollPhatRectangle(int(inputList[0]),int(inputList[1]),int(inputList[2]),int(inputList[3]),int(inputList[4]),int(inputList[5]),)', +'Phc':'a=wp.scrollPhatPutchar(int(inputList[0]))', +'PhP':'a=wp.scrollPhatPuts(inputList[0])', +'Phf':'a=wp.scrollPhatPrintf(inputList[0])', +'Phs':'a=wp.scrollPhatPrintSpeed(int(inputList[0]))', +'PhI':'a=wp.scrollPhatIntensity(int(inputList[0]),)', +'plC':'a=wp.pullUpDnControl(int(inputList[0]),int(inputList[1]))', +'pMA':'a=wp.pinModeAlt(int(inputList[0]),int(inputList[1]))', +'pN0':'if pinNum==0:\n\t\ta=wp.wiringPiSetup()\n\t\tpinNum=1\n\telse:\n\t\ta="RPI_pinNumbering has already been called once. Close and restart the connection to change the numbering sequence."', +'pN1':'if pinNum==0:\n\t\ta=wp.wiringPiSetupGpio()\n\t\tpinNum=2\n\telse:\n\t\ta="RPI_pinNumbering has already been called once. Close and restart the connection to change the numbering sequence."', +'pN2':'if pinNum==0:\n\t\ta=wp.wiringPiSetupPhys()\n\t\tpinNum=3\n\telse:\n\t\ta="RPI_pinNumbering has already been called once. Close and restart the connection to change the numbering sequence."', +'pN3':'if pinNum==0:\n\t\ta=wp.wiringPiSetupSys()\n\t\tpinNum=4\n\telse:\n\t\ta="RPI_pinNumbering has already been called once. Close and restart the connection to change the numbering sequence."()', +'pnM':'a=wp.pinMode(int(inputList[0]),int(inputList[1]))', +'pri':'a=wp.PiHiPri(int(inputList[0]))', +'ptG':'a=wp.physPinToGpio(int(inputList[0]))', +'pwC':'a=wp.pwmSetClock(int(inputList[0]))', +'pwG':'a=wp.wpiPinToGpio(int(inputList[0]))', +'pwM':'a=wp.pwmSetMode(int(inputList[0]))', +'pwR':'a=wp.pwmSetRange(int(inputList[0]))', +'pwT':'a=wp.pwmToneWrite(int(inputList[0]),int(inputList[1]))', +'pwW':'a=wp.pwmWrite(int(inputList[0]),int(inputList[1]))', +'sCl':'a=wp.serialClose(int(inputList[0]))', +'sDA':'a=wp.serialDataAvail(int(inputList[0]))', +'sFl':'a=wp.serialFlush(int(inputList[0]))', +'sGc':'a=wp.serialGetchar(int(inputList[0]))', +'shI':'a=wp.shiftIn(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'shO':'a=wp.shiftOut(int(inputList[0]),int(inputList[1]),int(inputList[2]),int(inputList[3]))', +'sn3':'a=wp.sn3218Setup(int(inputList[0]))', +'sOp':'a=wp.serialOpen(inputList[0],int(inputList[1]))', +'sPc':'a=wp.serialPutchar(int(inputList[0]),inputList[1])', +'sPC':'a=wp.softPwmCreate(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'SPD':'a=wp.wiringPiSPIDataRW(int(inputList[0]),inputList[1])', +'sPf':'a=wp.serialPrintf(int(inputList[0]),inputList[1])', +'SPF':'a=wp.wiringPiSPIGetFd(int(inputList[0]))', +'SPM':'a=wp.wiringPiSPISetupMode(int(inputList[0]),int(inputList[1]),int(inputList[2]))', +'SPS':'a=wp.wiringPiSPISetup(int(inputList[0]),int(inputList[1]))', +'sPs':'a=wp.serialPuts(int(inputList[0]),inputList[1])', +'sPS':'a=wp.softPwmStop(int(inputList[0]))', +'sPW':'a=wp.softPwmWrite(int(inputList[0]),int(inputList[1]))', +'sSS':'a=wp.softServoSetup(int(inputList[0]),int(inputList[1]),int(inputList[2]),int(inputList[3]),int(inputList[4]),int(inputList[5]),int(inputList[6]),int(inputList[7]))', +'sSW':'a=wp.softServoWrite(int(inputList[0]),int(inputList[1]))', +'sr5':'a=wp.sr595Setup(int(inputList[0]),int(inputList[1]),int(inputList[2]),int(inputList[3]),int(inputList[4]))', +'sTC':'a=wp.softToneCreate(int(inputList[0]))', +'sTS':'a=wp.softToneStop(int(inputList[0]))', +'sTW':'a=wp.softToneWrite(int(inputList[0]),int(inputList[1]))', +'thC':'a=wp.piThreadCreate(inputList[0])', +'unl':'a=wp.piUnlock(int(inputList[0]))', +'wtG':'a=wp.wpiPinToGpio(int(inputList[0]))', +#'rRT':'a=wp.readRHT03(int(inputList[0]),int(inputList[1]),inputList[2])', +'drc':'a=wp.drcSetupSerial(int(inputList[0]),int(inputList[1]),inputList[2],inputList[3])', +'ads':'a=wp.ads1115Setup(int(inputList[0]),int(inputList[1]))', +'wpF':'a=wp.wiringPiFailure(int(inputList[0]),inputList[1])', +'wpN':'a=wp.wiringPiFindNode(int(inputList[0]))', +'wpn':'a=wp.wiringPiNewNode(int(inputList[0]),int(inputList[1]))', +#'pBI':'a=wp.piBoardId()', +'gCS':'a=wp.gpioClockSet(int(inputList[0]),int(inputList[1]))', +#'':'a=wp.', +#'ISR':'if pinNum==1:\n\t\tpin=wp.wpiPinToGpio(29)\n\telif pinNum==2:\n\t\tpin=int(inputList[0])\n\telif pinNum==3:\n\t\t pin=wp.physPinToGpio(int(inputList[0]))\n\tGPIO.setup(pin,GPIO.IN,pull_up_down=inputList[2])\n\tGPIO.add_event_detect(pin,exec(inputList[1]),send2Client)', +} + +s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) +s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) +s.bind(("0.0.0.0",9077)) +""" +s2=socket.socket() +s2.connect((addr[0],9078)) + +def send2Client(pin): + s2.send(pin) +""" +s.listen(5) +go=1 +while go==1: + c, addr=s.accept() + theInput=c.recv(1024) + cmd=theInput[:3] + hash1=3 + Len=len(theInput) + for j in range(hash1+1,Len): + if theInput[j]=='#': + hash2=j + break + numInputs=int(theInput[hash1+1:hash2]) + hash1=hash2 + inputList=[] + for i in range(0,numInputs): + for j in range(hash1+1,Len): + if theInput[j]=='#': + hash2=j + break + inputList.append(theInput[hash1+1:hash2]) + hash1=hash2 + print ('try:\n\t'+commands[cmd]+'\nexcept Exception as err:\n\ta=traceback.format_exc()') + exec('try:\n\t'+commands[cmd]+'\nexcept Exception as err:\n\ta=traceback.format_exc()') + c.send(str(a)) + c.close() |