forked from iulikik/ChainMaster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotes.rtf
More file actions
355 lines (273 loc) · 8.93 KB
/
Notes.rtf
File metadata and controls
355 lines (273 loc) · 8.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
{\fonttbl\f0\fmodern\fcharset0 Courier;\f1\fnil\fcharset0 AndaleMono;\f2\fnil\fcharset0 Monaco;
\f3\fnil\fcharset0 Menlo-Regular;\f4\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;\red44\green44\blue44;\red0\green0\blue0;\red0\green0\blue0;
\red225\green226\blue231;\red31\green32\blue41;\red20\green156\blue146;\red69\green187\blue62;\red215\green0\blue143;
\red211\green35\blue46;\red255\green255\blue255;\red38\green38\blue38;\red47\green255\blue18;\red0\green0\blue0;
\red46\green174\blue187;\red159\green160\blue28;\red47\green180\blue29;\red64\green11\blue217;}
{\*\expandedcolortbl;;\cssrgb\c22745\c22745\c22745;\csgray\c0\c0;\cssrgb\c0\c0\c0;
\csgenericrgb\c88217\c88535\c90427;\csgenericrgb\c12157\c12549\c16078;\csgenericrgb\c7843\c61177\c57255;\csgenericrgb\c26985\c73392\c24249;\csgenericrgb\c84398\c0\c55980;
\csgenericrgb\c82745\c13725\c18039;\cssrgb\c100000\c100000\c100000;\cssrgb\c20000\c20000\c20000;\cssrgb\c15686\c99608\c7843;\csgray\c0\c90000;
\cssrgb\c20198\c73241\c78251;\cssrgb\c68469\c68013\c14209;\cssrgb\c20239\c73899\c14948;\cssrgb\c32309\c18668\c88228;}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
\f0\fs28 \cf2 \cb3 \expnd0\expndtw0\kerning0
# a guide to install server for motor_control server\
# in case your SSH key not working and you get something like this\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0
\f1\fs24 \cf4 \kerning1\expnd0\expndtw0 \CocoaLigature0 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\
#@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @\
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\f0\fs28 \expnd0\expndtw0\kerning0
\CocoaLigature1 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
\cf2 \
# use this command\
\
>ssh-keygen -R "you server hostname or ip"\
\pard\pardeftab720\partightenfactor0
\cf2 \
\
# so, now lets update and upgrade our raspberry pi and install additional libraries\
\
>sudo apt-get update\
>sudo apt-get dist-upgrade\
>sudo apt-get rpi.gpio\
>sudo apt-get install python-twisted\
\
# do not forget to make our raspberry pi have a static ip address \
\
\f2 \'97\'97\'97\'97\'97\'97\'97\'97\'97\'97 this part is missing for now \'97\'97\'97\'97\'97\'97\'97\'97\'97\'97
\f0 \
\
# lets create our script\
\
>sudo nano /home/pi/iphoneserver.py\
\
# here\'92s the script:\
\
\pard\tx593\pardeftab593\pardirnatural\partightenfactor0
\f3\fs24 \cf5 \cb6 \kerning1\expnd0\expndtw0 from twisted.internet.protocol import Protocol, Factory
\f4 \cf0 \
\f3 \cf5 from twisted.internet import reactor
\f4 \cf0 \
\
\f3 \cf5 import RPi.GPIO as GPIO
\f4 \cf0 \
\
\f3 \cf5 GPIO.setmode(GPIO.BCM)
\f4 \cf0 \
\
\f3 \cf5 pinList = [\cf7 2\cf5 , \cf7 3\cf5 , \cf7 4\cf5 , \cf7 17\cf5 , \cf7 27\cf5 , \cf7 22\cf5 , \cf7 10\cf5 , \cf7 9\cf5 ]
\f4 \cf0 \
\
\f3 \cf8 # loop through pins and set mode and state to 'low'
\f4 \cf0 \
\
\f3 \cf9 for\cf5 i \cf9 in\cf5 pinList:
\f4 \cf0 \
\f3 \cf5 GPIO.setup(i, GPIO.OUT)
\f4 \cf0 \
\f3 \cf9 for\cf5 i \cf9 in\cf5 pinList:
\f4 \cf0 \
\f3 \cf5 GPIO.output(i, GPIO.HIGH)
\f4 \cf0 \
\
\f3 \cf5 class RaspberryLight(Protocol):
\f4 \cf0 \
\f3 \cf5 def connectionMade(self):
\f4 \cf0 \
\f3 \cf8 #self.transport.write("""connected""")
\f4 \cf0 \
\f3 \cf5 self.factory.clients.append(self)
\f4 \cf0 \
\f3 \cf5 print \cf10 "clients are "\cf5 , self.factory.clients
\f4 \cf0 \
\
\f3 \cf5 def connectionLost(self, reason):
\f4 \cf0 \
\f3 \cf5 print \cf10 "connection lost "\cf5 , self.factory.clients
\f4 \cf0 \
\f3 \cf5 self.factory.clients.remove(self)
\f4 \cf0 \
\
\f3 \cf5 def dataReceived(self, data):
\f4 \cf0 \
\f3 \cf5 msg = \cf10 ""
\f4 \cf0 \
\
\f3 \cf9 if\cf5 (data == \cf10 'Motor1UP'\cf5 ): \cf8 #motor1 UP
\f4 \cf0 \
\f3 \cf5 msg = \cf10 "Motor 1 UP"
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 2\cf5 , GPIO.LOW)
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 3\cf5 , GPIO.HIGH)
\f4 \cf0 \
\
\f3 \cf9 if\cf5 (data == \cf10 'Motor1STOP'\cf5 ): \cf8 #motor1 STOP
\f4 \cf0 \
\f3 \cf5 msg = \cf10 "Motor 1 Stop"
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 2\cf5 , GPIO.HIGH)
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 3\cf5 , GPIO.HIGH)
\f4 \cf0 \
\
\f3 \cf9 if\cf5 (data == \cf10 'Motor1DOWN'\cf5 ): \cf8 #motor1 DOWN
\f4 \cf0 \
\f3 \cf5 msg = \cf10 "Motor 1 Down"
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 2\cf5 , GPIO.HIGH)
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 3\cf5 , GPIO.LOW)
\f4 \cf0 \
\
\f3 \cf9 if\cf5 (data == \cf10 'Motor2UP'\cf5 ): \cf8 #motor2 UP
\f4 \cf0 \
\f3 \cf5 msg = \cf10 "Motor 2 UP"
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 4\cf5 , GPIO.LOW)
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 17\cf5 , GPIO.HIGH)
\f4 \cf0 \
\
\f3 \cf9 if\cf5 (data == \cf10 'Motor2STOP'\cf5 ): \cf8 #motor2 STOP
\f4 \cf0 \
\f3 \cf5 msg = \cf10 "Motor 2 Stop"
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 4\cf5 , GPIO.HIGH)
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 17\cf5 , GPIO.HIGH)
\f4 \cf0 \
\
\f3 \cf9 if\cf5 (data == \cf10 'Motor2DOWN'\cf5 ): \cf8 #motor2 DOWN
\f4 \cf0 \
\f3 \cf5 msg = \cf10 "Motor 2 Down"
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 4\cf5 , GPIO.HIGH)
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 17\cf5 , GPIO.LOW)
\f4 \cf0 \
\
\f3 \cf9 if\cf5 (data == \cf10 'Motor3UP'\cf5 ): \cf8 #motor3 UP
\f4 \cf0 \
\f3 \cf5 msg = \cf10 "Motor 3 UP"
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 27\cf5 , GPIO.LOW)
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 22\cf5 , GPIO.HIGH)
\f4 \cf0 \
\
\f3 \cf9 if\cf5 (data == \cf10 'Motor3STOP'\cf5 ): \cf8 #motor3 STOP
\f4 \cf0 \
\f3 \cf5 msg = \cf10 "Motor 3 Stop"
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 27\cf5 , GPIO.HIGH)
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 22\cf5 , GPIO.HIGH)
\f4 \cf0 \
\
\f3 \cf9 if\cf5 (data == \cf10 'Motor3DOWN'\cf5 ): \cf8 #motor3 DOWN
\f4 \cf0 \
\f3 \cf5 msg = \cf10 "Motor 3 Down"
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 27\cf5 , GPIO.HIGH)
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 22\cf5 , GPIO.LOW)
\f4 \cf0 \
\
\f3 \cf9 if\cf5 (data == \cf10 'Motor4UP'\cf5 ): \cf8 #motor4 UP
\f4 \cf0 \
\f3 \cf5 msg = \cf10 "Motor 4 UP"
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 10\cf5 , GPIO.LOW)
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 9\cf5 , GPIO.HIGH)
\f4 \cf0 \
\
\f3 \cf9 if\cf5 (data == \cf10 'Motor4STOP'\cf5 ): \cf8 #motor4 STOP
\f4 \cf0 \
\f3 \cf5 msg = \cf10 "Motor 4 Stop"
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 10\cf5 , GPIO.HIGH)
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 9\cf5 , GPIO.HIGH)
\f4 \cf0 \
\
\f3 \cf9 if\cf5 (data == \cf10 'Motor4DOWN'\cf5 ): \cf8 #motor4 DOWN
\f4 \cf0 \
\f3 \cf5 msg = \cf10 "Motor 4 Down"
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 10\cf5 , GPIO.HIGH)
\f4 \cf0 \
\f3 \cf5 GPIO.output(\cf7 9\cf5 , GPIO.LOW)
\f4 \cf0 \
\
\
\f3 \cf5 print msg
\f4 \cf0 \
\
\f3 \cf5 factory = Factory()
\f4 \cf0 \
\f3 \cf5 factory.protocol = RaspberryLight
\f4 \cf0 \
\f3 \cf5 factory.clients = []
\f4 \cf0 \
\
\f3 \cf5 reactor.listenTCP(\cf7 7777\cf5 , factory)
\f4 \cf0 \
\f3 \cf5 print \cf10 "RaspberryLight server started"
\f4 \cf0 \
\f3 \cf5 reactor.run()
\f2\fs26 \cf11 \cb12 \expnd0\expndtw0\kerning0
\
\pard\pardeftab720\partightenfactor0
\f0\fs28 \cf2 \cb3 \
\
# for a test we can start our server\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0
\f1\fs24 \cf13 \cb14 \kerning1\expnd0\expndtw0 \CocoaLigature0 sudo nice -n 10 python /home/pi/iphoneserver.py
\f0\fs28 \cf2 \cb3 \expnd0\expndtw0\kerning0
\CocoaLigature1 \
\
# ctrl+c to stop server\
# after all tests we can >sudo nano /etc/rc.local to boot our server after restart\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0
\f1\fs24 \cf15 \cb14 \kerning1\expnd0\expndtw0 \CocoaLigature0 #!/bin/sh -e\cf13 \
\cf15 #\cf13 \
\cf15 # rc.local\cf13 \
\cf15 #\cf13 \
\cf15 # This script is executed at the end of each multiuser runlevel.\cf13 \
\cf15 # Make sure that the script will \cf16 "exit 0"\cf15 on success or any other\cf13 \
\cf15 # value on error.\cf13 \
\cf15 #\cf13 \
\cf15 # In order to enable or disable this script just change the execution\cf13 \
\cf15 # bits.\cf13 \
\cf15 #\cf13 \
\cf15 # By default this script does nothing.\cf13 \
\
\cf15 # Print the IP address\cf13 \
_IP\cf17 =$(\cf13 hostname -I\cf17 )\cf13 \cf17 ||\cf13 true\
\cf17 if\cf13 \cf17 [\cf13 \cf16 "$_IP"\cf13 \cf17 ];\cf13 \cf17 then\cf13 \
\cf18 printf\cf13 \cf16 "My IP address is %s\\n"\cf13 \cf16 "$_IP"\cf13 \
\cf17 fi\cf13 \
sudo nice \cf17 -n\cf13 10 python /home/pi/iphoneserver.py \cf17 &\cf13 \
\cf17 exit\cf13 0\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0
\f0\fs28 \cf2 \cb3 \expnd0\expndtw0\kerning0
\CocoaLigature1 \
\
# and finaly\
\
>sudo reboot\
\
\
\
########## IOS APPLICATION CODE ##########\
\
\
}