//////////////////////////////////////////////////////////////////////// // reader.cpp : Implementation of class CReader // // $Log: reader.cpp,v $ // Revision 1.2 1997/07/23 18:32:33 nettleto // Chnaged size to unsigned. // // Revision 1.1 1997/06/13 18:11:53 nettleto // Initial revision // // #include "reader.h" #include "tcu.h" #include #include void CReader::Get_Input_Line (char *Buf, unsigned size) { m.Lock (); if (strlen (Input_Line) < size) strcpy (Buf, Input_Line); else if (size > 0) { strncpy (Buf, Input_Line, size); Buf [size - 1] = '\0'; } m.Unlock (); } // Body for command interpreter thread // void CReader::Body () { int pos = 0; int ch; for (;;) { // Get character b->Get (ch); // Process character if (ch) { // Exit program, if requested if (ch == '~') { return; } if ((ch != '\n') && (ch != '\r') && (pos < BLEN)) { // Store character in input buffer m.Lock (); Input_Line[pos++] = ch; Input_Line[pos] = '\0'; m.Unlock (); } else if ((ch == '\n') || (ch == '\r')) { char *p = Input_Line; pos = 0; m.Lock (); /* act on command */ if (*p == 'T') { p++; if (*p == '1' || *p == '2' || *p == '3') { int i = *p - '0' - 1; p++; if (strcmp (p, "_AUTO") == 0) pTCU [i]->Set_Auto (); else if (strcmp (p, "_MAN") == 0) pTCU [i]->Set_Off (); else if (strcmp (p, "_ON") == 0) pTCU [i]->Set_On (); else if (strcmp (p, "_OFF") == 0) pTCU [i]->Set_Off (); } } m.Unlock (); } } sched_yield (); } }