comparison host/tools/ecostest/common/ResetAttributes.h @ 82:6736c52df507 ecos-sw-2000-04-14

Merge from eCos master repository on 2000-04-14-13:35:46-BST
author jlarmour
date Tue, 18 Apr 2000 21:51:55 +0000
parents 435cced73e2f
children 74dbf4c3f2e1
comparison
equal deleted inserted replaced
81:89fef2181d7d 82:6736c52df507
34 //####DESCRIPTIONEND#### 34 //####DESCRIPTIONEND####
35 35
36 #ifndef _RESETATTRIBUTES_H 36 #ifndef _RESETATTRIBUTES_H
37 #define _RESETATTRIBUTES_H 37 #define _RESETATTRIBUTES_H
38 38
39 #include "Collections.h"
39 #include "eCosStd.h" 40 #include "eCosStd.h"
40 #include "eCosTestSerial.h" 41 #include "eCosSerial.h"
41 #include "eCosTestSocket.h" 42 #include "eCosSocket.h"
42 #include "Properties.h" 43 #include "Properties.h"
43 44
44 class CTestResource; 45 //=================================================================
46 // This class deals with resetting a target.
47 // The ctor accepts the "reset string" this is something like
48 // expect($T05,#) 3(off(ginga:5000,a1) delay(2000) on(,..com2,38400))
49 // and is parsed to generate the commands to reset the target.
50 // The syntax is:
51 // resetstring :== [directive | <integer>(resetstring)] *
52 // directive :== id(arg[,arg]*)
53 // directive :== port | action | delay | expect
54 //
55 // The <integer>(string) syntax repeats argument its until reset is achieved.
56 // Each directive is given by example below:
57 // expect:
58 // Expected string(s). e.g. expect(str1,str2,...).
59 // Arguments:
60 // The string(s) expected to be output by a target after reset.
61 // *all* supplied strings must be present *in order* in the reset string for a reset to be recognized as valid.
62 // port:
63 // Provide port information to apply to all subsequent off|on|on_off|off_on actions until overwritten.
64 // e.g. port(com1,38400,1000)
65 // Arguments:
66 // 0. Port
67 // 1. Baud
68 // 2. Read timeout
69 // These have the meanings described under off|on|on_off|off_on.
70 // off|on|on_off|off_on:
71 // Request a reset host to perform a "power cycle" (or its logical equivalent -
72 // the meanings of "off" and "on" may depend on the reset host)
73 // e.g. off_on(ginga:500,A4,com1,38400,10000,1000)
74 // Arguments:
75 // 0. Reset host:port
76 // 1. Control string (meaning known to the reset host)
77 // 2. Port (from which to read startup output)
78 // 3. Baud for the above
79 // 4. Read timeout
80 // 5. Delay (between off and on or vice versa)
81 // delay:
82 // Delay for a given time right now.
83 // e.g. delay(1000)
84 // Arguments:
85 // 0. msec to delay
86 //=================================================================
45 87
46 class CResetAttributes { 88 class CResetAttributes {
47 public: 89 public:
48 bool IsValid(); 90 CResetAttributes(LPCTSTR psz=_T(""));
49 CResetAttributes(LPCTSTR psz=_T("")) : m_str(psz) {} 91
92 //bool IsValid();
93
50 const LPCTSTR Image() const { return m_str; } 94 const LPCTSTR Image() const { return m_str; }
51 static bool IsError(int n) { return n>=RESET_ILLEGAL_DEVICE_CODE && n<=RESET_UNKNOWN_ERROR; } 95
52 static LPCTSTR Image(int nErr); 96 bool IsNull() const { return m_str.empty(); }
53 bool IsNull() const { return 0==m_str.GetLength(); }
54 static const CResetAttributes NoReset; 97 static const CResetAttributes NoReset;
55 98
56 // Perform reset
57 enum ResetResult {INVALID_STRING=-1,RESET_OK=0,NOT_RESET=1, 99 enum ResetResult {INVALID_STRING=-1,RESET_OK=0,NOT_RESET=1,
58 RESET_ILLEGAL_DEVICE_CODE=30000,RESET_NO_REPLY, RESET_BAD_CHECKSUM, RESET_BAD_ACK, RESET_UNKNOWN_ERROR}; 100 RESET_ILLEGAL_DEVICE_CODE=30000,RESET_NO_REPLY, RESET_BAD_CHECKSUM, RESET_BAD_ACK, RESET_UNKNOWN_ERROR};
59 101
102 // Perform the reset, sending the output to the log function supplied as parameter.
103 ResetResult Reset (LogFunc *pfnLog=0, void *pfnLogparam=0,bool bCheckOnly=false);
104
60 enum Action {OFF=0,ON=1,OFF_ON=2,ON_OFF=3}; 105 enum Action {OFF=0,ON=1,OFF_ON=2,ON_OFF=3};
61
62 ResetResult Reset (LogFunc *pfnLog=0, void *pfnLogparam=0,bool bCheckOnly=false);
63 static bool CALLBACK IsValidReset (void *);
64 106
65 protected: 107 protected:
66 108
109 // This function determines whether the board startup has output all that is required
110 // All the strings of m_arValidResetStrings [arguments of expect() in the reset string] must be present
111 bool IsValidReset();
112
67 Time m_tResetOccurred; 113 Time m_tResetOccurred;
68 void ResetLog(LPCTSTR psz); 114
115 // The log function.
69 LogFunc *m_pfnReset; 116 LogFunc *m_pfnReset;
70 void *m_pfnResetparam; 117 void *m_pfnResetparam;
118 // Log some output to the reset log function.
119 void ResetLog(LPCTSTR psz);
71 120
72 CeCosTestSerial m_Serial; 121 CeCosSerial m_Serial;
73 CeCosTestSocket m_Socket; 122 CeCosSocket m_Socket;
74 123
75 const TCHAR *GetIdAndArg (LPCTSTR psz,String &strID,String &strArg); 124 const TCHAR *GetIdAndArg (LPCTSTR psz,String &strID,String &strArg);
76 ResetResult Parse (LPCTSTR psz,bool bCheckOnly=false); 125 ResetResult Parse (LPCTSTR psz,bool bCheckOnly=false);
77 bool Reset (Action action,bool bCheckOutput); 126 bool Reset (Action action,bool bCheckOutput);
78 127
79 void SuckThreadFunc (); 128 void SuckThreadFunc ();
80 static void CALLBACK SSuckThreadFunc (void *pParam) { ((CResetAttributes*)pParam)->SuckThreadFunc(); } 129 static void CALLBACK SSuckThreadFunc (void *pParam) { ((CResetAttributes*)pParam)->SuckThreadFunc(); }
81 int GetArgs(LPCTSTR psz,StringArray &ar);
82 130
83 String m_str; // Could be const, but avoid the assignment operator warnings 131 String m_str; // Here is the reset string. Could be const, but avoid the assignment operator warnings
84 132
85 String m_strHostPort; // host we talk to 133 // These members hold the information we extract by parsing the string:
86 String m_strControl; // Control string
87 int m_nDelay; // Delay between power off and power on
88 String m_strAuxPort; // Auxiliary port (serial port to listen on if primary port is TCP/IP)
89 int m_nReadTimeout; // mSec to wait for board to say something
90 int m_nBaud;
91 134
92 String m_strResetOutput; 135 StringArray m_arValidResetStrings;
136 String m_strHostPort; // host we talk to
137 String m_strControl; // Control string
138 int m_nDelay; // Delay between power off and power on
139 String m_strAuxPort; // Auxiliary port (serial port to listen on if primary port is TCP/IP)
140 int m_nReadTimeout; // mSec to wait for board to say something
141 int m_nBaud; // Baud rate
142
143 String m_strResetOutput; // The output we get
93 }; 144 };
94 145
95 #endif 146 #endif