#include #include #include #include #include #define STL_USE_INT_DICT #include "htae/p.h" void print(char *s){printf("%s",s);}//Define TX for STP void setup(){ #define CO __COUNTER__ int f=CO+1; stl_names[CO-f]=""; stl_names[CO-f]="proca"; stl_names[CO-f]="procb"; stl_names[CO-f]="confa"; stl_names[CO-f]="confb"; stl_help[1]="\tThis is a fake device"; stl_help[2]="simultated by a program."; stl_help[3]="Try changing some values!"; stl_name="fake"; stl_process_state="proca procb"; stl_vals[stl_namei("proca")]=2; stl_vals[stl_namei("procb")]=3; stl_vals[stl_namei("confa")]=4; stl_vals[stl_namei("confb")]=5; } static DWORD WINAPI lexerthread(void *threadParams){ //heh, its not really threadsafe //but the other thread *shouldn't* be writting(except the report counter) //It's possible that the report data might get garbled //but it's good enough for just testing the GUI app while(1){ char c=0; for(c=getchar();c!=EOF&&c!=-1;c=getchar()){ stl_recc(c); } if(c<0||c==EOF)break; fflush(stdout); } return 0; } int managecoms(uintptr_t td){ static double t=0; stl_report(); t=t+0.001; stl_vals[stl_namei("procb")]=sin(t); DWORD res=WaitForSingleObject(&td,200); switch(res){ case WAIT_OBJECT_0: return 0; case WAIT_TIMEOUT: return 1; //default: printf("bad cheese:%d not %d or %d\n",res,WAIT_OBJECT_0,WAIT_TIMEOUT);abort(); } Sleep(100); return 1; } int main() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); setup(); uintptr_t td=_beginthread(lexerthread,9000,NULL);// for those of you wondering //no that's an unsinged long int and NOT an unsinged long int * //which is also sometimes used as a DWORD? //I don't like win32 //CreateThread(NULL,0,lexerthread,&td,0,&td); while(managecoms(td)); return 0; }