Skip to content

Commit

Permalink
ADD: ESP8266 #4
Browse files Browse the repository at this point in the history
  • Loading branch information
anak10thn committed Mar 19, 2018
1 parent 2223d82 commit 04bd52a
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 38 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ BUILD_DIRS := src

all: $(BUILD_DIRS)

esp8266: $(BUILD_DIRS)

install: $(BUILD_DIRS)

uninstall: $(BUILD_DIRS)
Expand Down
7 changes: 7 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ all:
@echo "................................................"
@echo "Makefile: Available actions: install, uninstall"

esp8266:
@echo "Compiling to ESP8266 board"
@mkdir -p $(BIN_DIR)
@xtensa-lx106-elf-gcc -o $(BIN_DIR)/baik.elf -DESP8266 $(INCLUDES) $(LIBS) tbaik.c baik_ident.c baik_stack.c baik_expression.c baik_compare.c baik_factor.c interpreter.c interpreterSub.c interpreterClass.c sqlite_common.c -lpthread -lm
@echo "................................................"
@echo "Makefile: Available actions: install, uninstall"

install:
-install -d -m 755 $(PREFIX)/bin
-cp -R -L $(BIN_DIR)/baik $(PREFIX)/bin/
Expand Down
8 changes: 5 additions & 3 deletions src/baik_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ void Error( const char *format, ... );

#else

#ifndef ESP8266
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/select.h>
#endif

#include <sys/types.h>
#include <fcntl.h>
#include <regex.h>

#include <unistd.h>
#include <sys/param.h>

#include <arpa/inet.h>
#include <sys/select.h>
//#include "ux_pingbody.h"

#include <dirent.h>
Expand Down
12 changes: 6 additions & 6 deletions src/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,22 @@ extern char** win_dir_content(const char *path);

#else

#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>

#include <sys/types.h>
#include <fcntl.h>
#include <regex.h>

#include <unistd.h>
#include <sys/param.h>

#ifndef ESP8266
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/select.h>

#include <dirent.h>

DIR *owndir;
#endif

#endif

Expand Down
44 changes: 22 additions & 22 deletions src/interpreterSub.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#pragma warning(disable:4244)
#endif

extern BAIK_LEX lex;
extern BAIK_ADDR pg;
extern BAIK_LEX lex;
extern BAIK_ADDR pg;

#define MAX_SUB_DEPTH 64

Expand Down Expand Up @@ -66,7 +66,7 @@ void InterpreterSub( int endSub, char subName[MAX_STRING_LEN] )

Interpreter();

}while( pg.pt <= endSub && strncmp(lex.detail.string , "}", 1) != 0
}while( pg.pt <= endSub && strncmp(lex.detail.string , "}", 1) != 0
&& lex.type != _EOF );

sub_deep--;
Expand All @@ -90,7 +90,7 @@ void InterpreterLyrSub( int endSub, char subName[MAX_STRING_LEN] )

Interpreter();

}while( pg.pt <= endSub && strncmp(lex.detail.string , "}", 1) != 0
}while( pg.pt <= endSub && strncmp(lex.detail.string , "}", 1) != 0
&& lex.type != _EOF );

isLyrSub = 0;
Expand Down Expand Up @@ -118,7 +118,7 @@ int InterpreterTimerSub( int endSub, char subName[MAX_STRING_LEN] )
break;
}

}while( pg.pt <= endSub && strncmp(lex.detail.string , "}", 1) != 0
}while( pg.pt <= endSub && strncmp(lex.detail.string , "}", 1) != 0
&& lex.type != _EOF );

isTimerSub = 0;
Expand Down Expand Up @@ -156,7 +156,7 @@ void InterpreterParam( int progType, int endSub, char subName[MAX_STRING_LEN] )
// printf("param src: %s\n", pg.source);

do{

// first ident
getlex();
// printf("type %d ident: %s\n", lex.type, lex.detail.string);
Expand All @@ -172,7 +172,7 @@ void InterpreterParam( int progType, int endSub, char subName[MAX_STRING_LEN] )
if( lex.type == _EOF )
Error("interupsi yang tidak diinginkan");

if( lex.detail.symbol != '=' )
if( lex.detail.symbol != '=' )
Error("ident salah masukan");

// get value
Expand Down Expand Up @@ -214,7 +214,7 @@ void InterpreterParam( int progType, int endSub, char subName[MAX_STRING_LEN] )

}while( lex.type != _EOF && strncmp(lex.detail.string , "}", 1) != 0 );

}
}

}

Expand All @@ -223,7 +223,7 @@ void InterpreterLyrParam( int progType, int endSub, char subName[MAX_STRING_LEN]
int i=0;
VAL_LABEL valdat, valdat2, datx, tmpdat, tmpdat2;
char ident[MAX_STRING_LEN];
char class_tmpvar[MAX_STRING_LEN];
char class_tmpvar[MAX_STRING_LEN];

long idx=0; // array index
int tmp_deep = 0;
Expand Down Expand Up @@ -260,7 +260,7 @@ void InterpreterLyrParam( int progType, int endSub, char subName[MAX_STRING_LEN]
tmp_deep = sub_deep;

do{

// sub inside Lyr Function
// printf("inside lyr func loop : sub_deep %d, tmp_deep %d, isLyrSub %d\n", sub_deep, tmp_deep, isLyrSub);

Expand All @@ -283,7 +283,7 @@ void InterpreterLyrParam( int progType, int endSub, char subName[MAX_STRING_LEN]
if( lex.type == _EOF )
Error("interupsi yang tidak diinginkan");

if( lex.detail.symbol != '=' )
if( lex.detail.symbol != '=' )
Error("ident salah masukan");

// ///////////////////////
Expand Down Expand Up @@ -318,7 +318,7 @@ void InterpreterLyrParam( int progType, int endSub, char subName[MAX_STRING_LEN]

//printf("ident %s, sub deep %d\n", lex.detail.ident, sub_deep);

if(currentClass != NULL && strlen(currentClass) > 0) {
if(!currentClass && strlen(currentClass) > 0) {
sprintf(class_tmpvar, "%s->%s", currentClass, lex.detail.string);
//printf("tulis: construct class var: %s , deep %d\n", class_tmpvar, class_sub_deep);
//printf("start Class ValLabel ...\n");
Expand All @@ -338,7 +338,7 @@ void InterpreterLyrParam( int progType, int endSub, char subName[MAX_STRING_LEN]
sub_deep = 0;
tmp_deep = sub_deep;

if (currentClass != NULL && strlen(currentClass) > 0) {
if (!currentClass && strlen(currentClass) > 0) {
sprintf(class_tmpvar, "%s->%s", currentClass, lex.detail.string);
//printf("tulis: construct class var: %s , deep %d\n", class_tmpvar, class_sub_deep);
//printf("start Class ValLabel ...\n");
Expand Down Expand Up @@ -370,7 +370,7 @@ void InterpreterLyrParam( int progType, int endSub, char subName[MAX_STRING_LEN]
// printf("show NOT digit : %s\n", valdat.array_idx);
/* Read index param */

if(currentClass != NULL && strlen(currentClass) > 0) {
if(!currentClass && strlen(currentClass) > 0) {
sprintf(class_tmpvar, "%s->%s", currentClass, valdat.array_idx);
tmpdat = ValLabel( class_tmpvar, sub_deep, tmpdat, VAL_FLAG_SEARCH_R );
} else {
Expand All @@ -388,14 +388,14 @@ void InterpreterLyrParam( int progType, int endSub, char subName[MAX_STRING_LEN]

// get real value of array
// printf("search array: %s\n", valdat.array_name);
if(currentClass != NULL && strlen(currentClass) > 0) {
if(!currentClass && strlen(currentClass) > 0) {
memset(&class_tmpvar, '\0', sizeof(class_tmpvar));
sprintf(class_tmpvar, "%s->%s", currentClass, valdat.array_name);
valdat2 = ValLabel( class_tmpvar, class_sub_deep, valdat, VAL_FLAG_SEARCH_R );
} else {
valdat2 = ValLabel( valdat.array_name, sub_deep, valdat, VAL_FLAG_SEARCH_R );
}

// ltoa(idx, valdat2.array_idx, 10);
sprintf(valdat2.array_idx, "%li", idx);

Expand All @@ -406,20 +406,20 @@ void InterpreterLyrParam( int progType, int endSub, char subName[MAX_STRING_LEN]
//printf("valdat2 array name %s \n", valdat2.array_name);
//printf("valdat2 array_idx %d \n", idx);

if(valdat2.datatype == 60) { // Array GUI
if(valdat2.datatype == 60) { // Array GUI
#ifdef USE_GTK2
datx.widget = get_gui_array(valdat2, idx);
datx.eventbox = get_eventbox_array(valdat2, idx);
datx.GUItype = get_guitype_array(valdat2, idx);

//printf("interpretLyrParam : get GUI array, GUItype %d\n", datx.GUItype);
#endif
} else {
Error("salah jenis untaian");
}

} else {
// printf("NOT start...\n");
// printf("NOT start...\n");
}

datx.datatype = 40;
Expand All @@ -431,7 +431,7 @@ void InterpreterLyrParam( int progType, int endSub, char subName[MAX_STRING_LEN]
//printf("saving dbl ...%f\n", datx.floatdata);
// save ident

if(currentClass != NULL && strlen(currentClass) > 0) {
if(!currentClass && strlen(currentClass) > 0) {
memset(&class_tmpvar, '\0', sizeof(class_tmpvar));
sprintf(class_tmpvar, "%s->%s", currentClass, ident);
//printf("saving class var: %s %s\n", class_tmpvar);
Expand All @@ -451,6 +451,6 @@ void InterpreterLyrParam( int progType, int endSub, char subName[MAX_STRING_LEN]
if (isReSearch) {
sub_deep = tmp_deep;
}
}
}

}
15 changes: 8 additions & 7 deletions src/keyArrayDummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ void keyArrayDummy (char array_str[MAX_STRING_LEN])
memset(&tmpstr, '\0', sizeof(tmpstr));
memset(&class_tmpvar, '\0', sizeof(class_tmpvar));


// printf("dummy array = %d, tmp renban %d\n", checkDummyArray(lex.detail.array_str), renban );

getArrayName(array_str, (char *)&valdat.array_str);
getArrayName(array_str, (char *)&valdat.array_name);
strcpy(valdat.array_idx, "0");
Expand Down Expand Up @@ -116,8 +116,8 @@ void keyArrayDummy (char array_str[MAX_STRING_LEN])
Error("PISAH: masukan data salah");
} else {
/*
printf("a: %s\n", dat_a);
printf("b: %s\n", dat_b);
printf("a: %s\n", dat_a);
printf("b: %s\n", dat_b);
*/

if(tmpdat.datatype == 10) {
Expand Down Expand Up @@ -316,21 +316,23 @@ void keyArrayDummy (char array_str[MAX_STRING_LEN])
split_free(get);

ValLabel( valdat.array_name, sub_deep, valdat, VAL_FLAG_SEARCH_W );
memset(&valdat, '\0', sizeof(valdat));
memset(&valdat, '\0', sizeof(valdat));

#ifdef WINDOWS
if(dirtp != NULL) {
free (dirtp);
}
#else
#ifndef ESP8266
if(owndir != NULL) {
closedir (owndir);
}
#endif
#endif

/* printf("write dummy array ok\n"); */

}
}
/* printf("endif array FUNC OK\n"); */

if(valdat.filename != NULL)
Expand Down Expand Up @@ -366,4 +368,3 @@ void keyArrayDummy (char array_str[MAX_STRING_LEN])
free(tmpdat.pnext);

}

0 comments on commit 04bd52a

Please sign in to comment.