1 /* 2 * Copyright 2012, Adrien Destugues, pulkomandy@gmail.com 3 * Distributed under the terms of the MIT licence. 4 */ 5 6 7 #ifndef _SERIALAPP_H_ 8 #define _SERIALAPP_H_ 9 10 11 #include <Application.h> 12 #include <PropertyInfo.h> 13 #include <SerialPort.h> 14 #include <String.h> 15 16 17 class BFile; 18 class SerialWindow; 19 20 21 class SerialApp: public BApplication 22 { 23 public: 24 SerialApp(); 25 ~SerialApp(); 26 void ReadyToRun(); 27 void MessageReceived(BMessage* message); 28 bool QuitRequested(); 29 30 status_t GetSupportedSuites(BMessage* message); 31 BHandler* ResolveSpecifier(BMessage*, int32, BMessage*, int32, 32 const char*); 33 34 const BString& GetPort(); 35 36 private: 37 void LoadSettings(); 38 void SaveSettings(); 39 40 private: 41 BSerialPort fSerialPort; 42 sem_id fSerialLock; 43 SerialWindow* fWindow; 44 BFile* fLogFile; 45 BString fPortPath; 46 47 static status_t PollSerial(void*); 48 49 static const BPropertyInfo kScriptingProperties; 50 static const char* kApplicationSignature; 51 }; 52 53 54 enum messageConstants { 55 kMsgDataRead = 'dare', 56 kMsgDataWrite = 'dawr', 57 kMsgLogfile = 'logf', 58 kMsgOpenPort = 'open', 59 kMsgSettings = 'stty', 60 }; 61 62 #endif 63