/[projects]/smsdaemon/tester.cpp
ViewVC logotype

Contents of /smsdaemon/tester.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 185 - (show annotations) (download)
Mon Dec 15 09:10:05 2008 UTC (15 years, 5 months ago) by torben
File size: 4318 byte(s)
Util, a new str_split which operates on whitespace

Make HostStatusPlugin return system memory usage


1 /* using http://sourceforge.net/projects/libserial/
2 *
3 */
4
5
6 #include <string>
7 #include <iostream>
8 #include <vector>
9 #include "serialport/SerialPort.h"
10
11 #include "DebugTransceiver.h"
12 #include "SmsToolTransceiver.h"
13 #include "plugins/HostStatusPlugin.h"
14 #include "Sms.h"
15 #include "plugins/TogPlugin.h"
16 #include "plugins/TrainInfo.h"
17 #include "Util.h"
18 #include "plugins/StatusPlugin.h"
19 #include "SmsPdu.h"
20
21 using namespace std;
22 using namespace Util;
23
24 void test_sms(ISmsTransceiver& modem, int len)
25 {
26 cout << "----- test_sms( " << len << " ) ------- " << endl;
27
28 string msg = Util::str_formatint(len);
29 msg.append(1, ' ');
30 msg.append(len - msg.length(), 'a');
31
32 vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("22337617", msg, true);
33
34 for (unsigned int i=0; i<pdu.size(); ++i)
35 {
36 cout << "#" << i << endl;
37 cout << "Len: " << pdu[i].len << endl;
38 cout << "Pdu: " << pdu[i].pdu << endl;
39
40 // modem.SendSmsPdu(pdu[i].pdu, pdu[i].len);
41 }
42 }
43
44
45 int main()
46 {
47 /*
48 int shift = 6;
49 string start = "Hej med dig";
50 string end = SmsPdu::Decode8to7bit(SmsPdu::Encode7to8bit(start,shift), shift );
51
52 cout << start << endl;
53 cout << end << endl;
54 return 0;
55 */
56
57
58 DebugTransceiver trans(true);
59 HostStatusPlugin pl;
60
61 SMS sms;
62
63 pl.Execute(trans,sms);
64
65
66
67 return 0;
68 string start = "hej ������";
69 string mid = str_latin2gsm(start);
70 string final = str_gsm2latin(mid);
71
72 str_dump (start);
73 str_dump(mid);
74 str_dump(final);
75
76
77 return 0;
78
79 /*
80 SerialPort port("/dev/ttyS1" );
81 port.Open( SerialPort::BAUD_9600,
82 SerialPort::CHAR_SIZE_8,
83 SerialPort::PARITY_NONE,
84 SerialPort::STOP_BITS_1,
85 SerialPort::FLOW_CONTROL_HARD );
86
87 ModemTransceiver modem(port);
88 modem.Init();
89
90
91 test_sms(modem, 100);
92 return 0;
93
94
95 vector<SMS> res = modem.ReadSms(true);
96
97 for (unsigned int i = 0; i<res.size(); ++i)
98 {
99 SMS& sms = res[i];
100 string cmd = GetSmsCommand(sms);
101 string data = GetSmsData(sms);
102 cout << "------------------------------" << endl;
103 cout << "Index " << sms.sms_index << endl;
104 cout << "Sender: " << sms.sender << endl;
105 cout << "Time: " << sms.timestamp << endl;
106 cout << "Message: >" << sms.message << "<" << endl;
107 cout << "Cmd: >" << cmd << "<" << endl;
108 cout << "Data >" << data << "<" << endl;
109
110 Util::str_dump(sms.message);
111 //modem.SendSms(sms.sender, sms.message, false);
112
113 }
114
115 */
116 /*
117 vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", "Hej med dig, igen", true);
118 cout << "Len: " << pdu[0].len << endl;
119 cout << "Pdu: " << pdu[0].pdu << endl;
120
121 modem.SendSmsPdu(pdu[0].pdu, pdu[0].len);
122 */
123
124
125
126 /*
127 SMS sms;
128 sms.sender = "12345678";
129 sms.message = "Tog list";
130 DebugModemTransceiver modem;
131 TogPlugin plugin;
132
133 plugin.Execute(modem, sms);
134
135
136 string msg = Util::str_gsm2latin(modem.GetMessage());
137
138 cout << "---- " << msg.length() << " ----" << endl;
139 cout << msg << endl;
140 */
141 /*
142 vector<TrainInfo> trains = GetTrainInfo("BJ","Bjerringbro");
143
144 for (unsigned i=0; i<trains.size(); ++i)
145 {
146 TrainInfo& train = trains[i];
147 cout << "-------------------------------------" << endl;
148 cout << "Time: {" << train.time << "}" << endl;
149 cout << "Update: {" << train.update << "}" << endl;
150 cout << "Type: {" << train.type << "}" << endl;
151 cout << "Destination:{" << train.destination << "}" << endl;
152 cout << "Origin: {" << train.origin << "}" << endl;
153 cout << "Current: {" << train.current << "}" << endl;
154 cout << "Status: {" << train.status << "}" << endl;
155 cout << "Note: {" << train.note << "}" << endl;
156 }
157 */
158 /*
159 SMS sms;
160
161 sms.message = "Test test2 teste3 test4";
162
163 cout << "|" << GetSmsCommand(sms) << "|" << GetSmsData(sms) << "|" << endl;
164
165 return 0;
166
167
168 SerialPort port("/dev/ttyS1" );
169 port.Open();
170 ModemTransceiver modem(port);
171
172 //modem.SendSms("22337617", "Hello, sir!");
173 //
174 vector<SMS> res = modem.ReadSms();
175
176
177 for (unsigned i=0; i<res.size(); ++i)
178 {
179 cout << "--- SMS Recieved ---" << endl;
180 cout << "Index: " << res[i].sms_index << endl;
181 cout << "From: " << res[i].sender << endl;
182 cout << "Time: " << res[i].timestamp << endl;
183 cout << "Message:>" << res[i].message << "<" << endl;
184 cout << endl;
185 modem.DeleteSms(res[i].sms_index);
186 }
187
188 for (int j=0; j<5; j++)
189 {
190 modem.SendSms("22337617","Test");
191 }
192 */
193 return 0;
194 }

  ViewVC Help
Powered by ViewVC 1.1.20