Hi,
Thank you all for the helpful responses!
I'm afraid I only have more questions at the moment.
@sonnyyu
I've just done a similar test and it generally seems about twice as slow:
ab -n 20 -c 1 http://192.168.240.1/arduino/byte/-1
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.240.1 (be patient).....done
Server Software:
Server Hostname: 192.168.240.1
Server Port: 80
Document Path: /arduino/byte/-1
Document Length: 18 bytes
Concurrency Level: 1
Time taken for tests: 6.843 seconds
Complete requests: 20
Failed requests: 0
Write errors: 0
Total transferred: 2380 bytes
HTML transferred: 360 bytes
Requests per second: 2.92 [#/sec] (mean)
Time per request: 342.163 [ms] (mean)
Time per request: 342.163 [ms] (mean, across all concurrent requests)
Transfer rate: 0.34 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 2 3 1.3 3 6
Processing: 228 339 46.5 346 421
Waiting: 211 322 47.4 329 418
Total: 231 342 46.5 348 423
Percentage of the requests served within a certain time (ms)
50% 348
66% 351
75% 376
80% 390
90% 397
95% 423
98% 423
99% 423
100% 423 (longest request)
ab -n 20 -c 1 http://192.168.240.1/arduino/byte/-1
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.240.1 (be patient).....done
Server Software:
Server Hostname: 192.168.240.1
Server Port: 80
Document Path: /arduino/byte/-1
Document Length: 18 bytes
Concurrency Level: 1
Time taken for tests: 6.654 seconds
Complete requests: 20
Failed requests: 0
Write errors: 0
Total transferred: 2380 bytes
HTML transferred: 360 bytes
Requests per second: 3.01 [#/sec] (mean)
Time per request: 332.717 [ms] (mean)
Time per request: 332.717 [ms] (mean, across all concurrent requests)
Transfer rate: 0.35 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 3 1.6 3 8
Processing: 234 329 46.7 328 452
Waiting: 214 309 48.8 311 430
Total: 239 332 46.3 333 455
Percentage of the requests served within a certain time (ms)
50% 333
66% 351
75% 361
80% 367
90% 372
95% 455
98% 455
99% 455
100% 455 (longest request)
Any hints on what I should do to improve this ?
@Federico Fissore
I installed tornado and tried a sample:
import tornado.ioloop
import tornado.web
import tornado.websocket
import serial
from tornado.options import define, options, parse_command_line
ser = serial.Serial('/dev/ttyATH0', 57600)
define("port", default=8888, help="", type=int)
class WebSocketHandler(tornado.websocket.WebSocketHandler):
def open(self, *args):
print "Connected"
def on_message(self, message):
dato_1 = str(message)
print (message)
ser.write(dato_1)
def on_close(self):
print "Disconnected"
app = tornado.web.Application([
(r'/w/', WebSocketHandler),
])
if __name__ == '__main__':
parse_command_line()
app.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
and a test client:
<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<script>
//ws://192.168.0.9:8888
//weso://ARDUINO.YUN.IP.ADRESS:8888/w/
var connection = new WebSocket('ws://192.168.0.9:8888/ws/', ['soap', 'xmpp']);
connection.onopen = function () {
connection.send('Ping'); // Send the message 'Ping' to the server
};
// Log errors
connection.onerror = function (error) {
console.log('WebSocket Error ' + error);
};
// Log messages from the server
connection.onmessage = function (e) {
console.log('Server: ' + e.data);
};
</script>
</body>
</html>
but I always get a 404:
WebSocket connection to 'ws://192.168.0.9:8888/ws/' failed: Error during WebSocket handshake: Unexpected response code: 404
I've tried ws://192.168.0.9:8888 as well and I can see all these errors on my Yun as well:
root@yun:/www/ws# python ws.py
[W 140923 22:03:22 web:1811] 404 GET / (192.168.0.4) 12.83ms
[W 140923 22:07:42 web:1811] 404 GET /ws/ws.py (192.168.0.4) 10.97ms
[W 140923 22:13:11 web:1811] 404 GET /ws/ (192.168.0.4) 9.35ms
How do people get the example working on a yun ?
Also, regarding Spacebrew, I'm afraid I've tried that before with little success on the Yun so far:
http://forum.spacebrew.cc/t/issues-using-arduino-yun/57
Thank you all again for your contributions.
Looking forward to your responses.