00001 /* 00002 * Board.h is a header file defining necessary functionality for the Board. 00003 * 00004 * Copyright (c).2012. OWNER: Institute for Software Technology, TU Graz Austria. 00005 * Authors: Safdar Zaman, Gerald Steinbauer. (szaman@ist.tugraz.at, steinbauer@ist.tugraz.at) 00006 * All rights reserved. 00007 * This program is free software: you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation, either version 3 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #include <sys/socket.h> 00022 #include <sys/types.h> 00023 #include <netinet/in.h> 00024 #include <netdb.h> 00025 #include <stdio.h> 00026 #include <string.h> 00027 #include <stdlib.h> 00028 #include <unistd.h> 00029 #include <errno.h> 00030 #include <pthread.h> 00031 #define STX '2' 00032 00033 class Message 00034 { 00035 public: 00036 Message(); 00037 ~Message(); 00038 void initMessage(); 00039 void parseBuffer(); 00040 char getBuffer(int *length); 00041 00042 00043 private: 00044 void create_threads(); 00045 char delim; 00046 char command; 00047 ushort length; 00048 char n; 00049 int max_curr; 00050 int max_vol; 00051 unsigned char nbuffer[255]; 00052 unsigned char * p; 00053 int sock, bytes_recieved; 00054 unsigned char send_data[255],recv_data[255]; 00055 struct hostent *host; 00056 struct sockaddr_in server_addr; 00057 bool sendSignal; 00058 00059 };