jjg / restduino Goto Github PK
View Code? Open in Web Editor NEWA sketch to provide a REST-like interface to the Arduino+Ethernet Shield
License: GNU General Public License v3.0
A sketch to provide a REST-like interface to the Arduino+Ethernet Shield
License: GNU General Public License v3.0
The above will not seem to bind with the Restduino sketch?
Hi,
I have an UNO r3 with an ethernet shield. When compiling I get below error.
To be honest, I have no idea how to start with this error. Hoping you can help me.
warning: NULL used in arithmetic [-Wpointer-arith]
Many thanks in advance!
Dirk
Arduino: 1.6.5 (Windows 7), Board: "Arduino Uno"
Build options changed, rebuilding all
Using library EthernetBonjour in folder: C:\Program Files (x86)\Arduino\libraries\EthernetBonjour (legacy)
Using library SPI in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI
Using library Ethernet in folder: C:\Program Files (x86)\Arduino\libraries\Ethernet
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Program Files (x86)\Arduino\libraries\Ethernet\src C:\Users\dirk\AppData\Local\Temp\build1197526729768169677.tmp\RESTduino.cpp -o C:\Users\dirk\AppData\Local\Temp\build1197526729768169677.tmp\RESTduino.cpp.o
RESTduino.ino: In function 'void loop()':
RESTduino.ino:229:31: warning: NULL used in arithmetic [-Wpointer-arith]
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Program Files (x86)\Arduino\libraries\Ethernet\src -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp -o C:\Users\dirk\AppData\Local\Temp\build1197526729768169677.tmp\EthernetBonjour\EthernetBonjour.cpp.o
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp: In member function 'int EthernetBonjourClass::_startMDNSSession()':
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:291:94: warning: comparison is always false due to limited range of data type [-Wtype-limits]
if (ethernet_compat_socket(this->_socket, ECSnMrUDP, MDNS_SERVER_PORT, ECSnMrMulticast) < 0)
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp: In member function 'int EthernetBonjourClass::_closeMDNSSession()':
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:306:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp: In member function 'MDNSError_t EthernetBonjourClass::_sendMDNSMessage(uint32_t, uint32_t, int, int)':
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:527:1: warning: label 'errorReturn' defined but not used [-Wunused-label]
errorReturn:
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp: At global scope:
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:311:13: warning: unused parameter 'peerAddress' [-Wunused-parameter]
MDNSError_t EthernetBonjourClass::_sendMDNSMessage(uint32_t peerAddress, uint32_t xid, int type,
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:311:13: warning: unused parameter 'serviceRecord' [-Wunused-parameter]
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp: In member function 'MDNSError_t EthernetBonjourClass::_processMDNSQuery()':
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:602:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i=0; i<qCnt; i++) {
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:656:48: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
ir = (tr > sizeof(DNSHeader_t)) ? sizeof(DNSHeader_t) : tr;
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:552:44: warning: variable 'aCnt' set but not used [-Wunused-but-set-variable]
uint16_t peer_port, udp_len, ptr, qCnt, aCnt, aaCnt, addCnt;
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:552:50: warning: variable 'aaCnt' set but not used [-Wunused-but-set-variable]
uint16_t peer_port, udp_len, ptr, qCnt, aCnt, aaCnt, addCnt;
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:552:57: warning: variable 'addCnt' set but not used [-Wunused-but-set-variable]
uint16_t peer_port, udp_len, ptr, qCnt, aCnt, aaCnt, addCnt;
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:1079:96: warning: 'peer_addr' may be used uninitialized in this function -Wmaybe-uninitializedthis->_sendMDNSMessage(peer_addr, xid, (int)MDNSPacketTypeServiceRecord, j-2);
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:1079:96: warning: 'xid' may be used uninitialized in this function [-Wmaybe-uninitialized]
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -Wall -Wextra -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Program Files (x86)\Arduino\libraries\Ethernet\src -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetUtil.c -o C:\Users\dirk\AppData\Local\Temp\build1197526729768169677.tmp\EthernetBonjour\utility\EthernetUtil.c.o
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetUtil.c:64:0: warning: ignoring #pragma mark [-Wunknown-pragmas]
#pragma mark -
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetUtil.c:65:0: warning: ignoring #pragma mark Private [-Wunknown-pragmas]
#pragma mark Private
^
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Program Files (x86)\Arduino\libraries\Ethernet\src -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp -o C:\Users\dirk\AppData\Local\Temp\build1197526729768169677.tmp\EthernetBonjour\utility\EthernetCompat.cpp.o
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp: In function 'uint16_t ethernet_compat_write_private(uint16_t, uint8_t_, uint16_t)':
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:54:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<len; i++) {
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp: At global scope:
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:66:6: warning: unused parameter 'rxtx_bufsize' [-Wunused-parameter]
void ethernet_compat_init(uint8_t macAddr, uint8_t* ipAddr, uint16_t rxtx_bufsize)
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp: In function 'void ethernet_compat_read_data(int, uint8_t_, uint8_t_, uint16_t)':
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:121:41: error: invalid conversion from 'uint8_t* {aka unsigned char_}' to 'uint16_t {aka unsigned int}' [-fpermissive]
W5100.read_data(socket, src, dst, len);
^
In file included from C:\Program Files (x86)\Arduino\libraries\Ethernet\src/utility/socket.h:4:0,
from C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:27:
C:\Program Files (x86)\Arduino\libraries\Ethernet\src/utility/w5100.h:148:8: error: initializing argument 2 of 'void W5100Class::read_data(SOCKET, uint16_t, volatile uint8_t_, uint16_t)' [-fpermissive]
void read_data(SOCKET s, volatile uint16_t src, volatile uint8_t * dst, uint16_t len);
^
Error compiling.
Hi I have a problem when checking the code
..
Documents\Arduino\sketch_feb05a\sketch_feb05a.ino: In function 'uint8_t getFingerprintEnroll()':
..
Documents\Arduino\sketch_feb05a\sketch_feb05a.ino:405:7: warning: return-statement with no value, in function returning 'uint8_t {aka unsigned char}' [-fpermissive]
C:\Users\YASIR\Documents\RESTduino\RESTduino.ino: In function 'void loop()':
C:\Users\YASIR\Documents\RESTduino\RESTduino.ino:230:31: warning: NULL used in arithmetic [-Wpointer-arith]
else if(pin[0] != NULL) {
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp: In function 'void ethernet_compat_read_data(int, uint8_t_, uint8_t_, uint16_t)':
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:121:41: error: invalid conversion from 'uint8_t* {aka unsigned char*}' to 'uint16_t {aka unsigned int}' [-fpermissive]
W5100.read_data(socket, src, dst, len);
^
In file included from C:\Program Files (x86)\Arduino\libraries\Ethernet\src/utility/socket.h:4:0,
from C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:27:
C:\Program Files (x86)\Arduino\libraries\Ethernet\src/utility/w5100.h:142:8: error: initializing argument 2 of 'void W5100Class::read_data(SOCKET, uint16_t, volatile uint8_t*, uint16_t)' [-fpermissive]
void read_data(SOCKET s, volatile uint16_t src, volatile uint8_t * dst, uint16_t len);
^
exit status 1
Error compiling for board Arduino Ethernet.
Hi,
I have something strange going on here.
When i open http://192.168.1.177/6/LOW the led goes on, and HIGH it turns of.
Am i doing wrong, or is there a bug?
It's a brand new arduino ethernet, just uploaded the sketch, used same ip and mac address as in the example.
attached a led to port 6 and 3v.
Cheers,
Tom
C:\Users\Tomasz\Documents\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:27:28: fatal error: utility/socket.h: No such file or directory
#include <utility/socket.h>
compilation terminated.
exit status 1
Need to return CORS heaers lest browsers talking directly to RESTDuino become angry.
Interestingly this doesn't seem to impact "write" operations, i.e., you can issue GET requests that are processed by RESTDuino, but the browser rejects the response. I haven't tested it yet, but my guess is that "read" operations will fail altogether.
So, RESTDuino should return the necessary CORS headers to make the browsers know it's OK to talk to RESTDuino.
Hi guys
If a browser send more than 255 char (buffer size) or missing some \n stuff, the buffer could be not terminated by 0, this crashe the string manipulation after and stop the application
Always more robust when we work with string to assure that a zero exists somewhere marking the end of the string.
I added the 3 lines in the code below all is working fine on my side now ;-)
Charles
if (client)
{
// reset input buffer
index = 0;
// Added clearing buffer starting clean
// ===========================
for (int i = 0; i < (sizeof(clientline)); i++)
clientline[i] = '\0';
...
...
// fill url the buffer
if(c != '\n' && c != '\r' && index < BUFSIZE)
{
clientline[index++] = c;
continue;
}
// Add this new line at this point
// =====================
clientline[index] = '\0' ;
Hi ,
I made a shell script that reads the analog pin 0 constantly with a delay of 10 seconds, using the curl command.
After the third reading , the arduino hangs out and the program only returns to function if I reset the arduino.
The same thing does not happen if I use a script that switches a led, on and off, with the same frequency.
I am using the following script on a MAC OSX 10.6:
while true
do
curl http://192.169.1.201/a0
sleep 10
done
Is there a minimum delay between readings ?
Thanks in advance
Opening this issue as a followup to the posterous thread:
http://jasongullickson.posterous.com/restduino-arduino-hacking-for-the-rest-of-us
"I am looking at either updating the RESTduino sketch to allow JSONP callbacks or CORS headers in order to allow cross-domain requests."
The idea would you can call RESTduino with:
http://192.168.1.177/a0?callback=functioname
with response of
functioname({"a0":"349"});
Changes to RESTduino.pde I reckon will be quite minor, just need to parse the "?callback" parameter, wrap the JSON in parentheses, and then prepend the value of "callback" to the response.
Or....I might just add "Access-Control-Allow-Origin: * " to the header....a little easier :)
CORS is inherently cleaner, embracing the latest web standards for cross-origin resources. Native XMLHttpRequest can be made in modern browsers without the need for proxies or callback functions.
CORS is so far a relatively new technology, and not compatible with alot of browsers out there. We'll add a "Access-Control-Allow-Origin: *" header to the HTTP response, but also allow JSONP callbacks for another cross-origin method.
Hi,
Sorry this is more of a questions than a issue really, I am considering purchasing a shield that will allow internet connections for my arduino, however I was not sure if I would be able to use this library with a wireless shield. I would have thought it was possible, but I wanted to make sure.
Is there any wireless shields you recommend?
Thanks.
There is a typo on lines 32 and 53 of RESTduino.ino. Instead of STATICPIP, it should be STATICIP (there is an extra P).
Only the slide action sends an update. A click on the slider dies not set the value.
I got an error compiling my sketch.
Could you help me?
Arduino: 1.6.8 (Windows 7), Board: "Arduino Duemilanove or Diecimila, ATmega328"
RESTduino.ino: In function 'void loop()':
RESTduino.ino:230:31: warning: NULL used in arithmetic [-Wpointer-arith]
else if(pin[0] != NULL) {
^
sketch\libraries\EthernetBonjour\utility\EthernetCompat.cpp: In function 'void ethernet_compat_read_data(int, uint8_t_, uint8_t_, uint16_t)':
sketch\libraries\EthernetBonjour\utility\EthernetCompat.cpp:121:41: error: invalid conversion from 'uint8_t* {aka unsigned char*}' to 'uint16_t {aka unsigned int}' [-fpermissive]
W5100.read_data(socket, src, dst, len);
^
In file included from C:\Program Files (x86)\Arduino\libraries\Ethernet\src/utility/socket.h:4:0,
from sketch\libraries\EthernetBonjour\utility\EthernetCompat.cpp:27:
C:\Program Files (x86)\Arduino\libraries\Ethernet\src/utility/w5100.h:142:8: error: initializing argument 2 of 'void W5100Class::read_data(SOCKET, uint16_t, volatile uint8_t*, uint16_t)' [-fpermissive]
void read_data(SOCKET s, volatile uint16_t src, volatile uint8_t * dst, uint16_t len);
^
exit status 1
Error compiling for board Arduino Duemilanove or Diecimila.
I was trying callback parameters like so for JSONP when I froze the Arduino and Shield:
http://192.168.1.50/ao?callback=junk
One of the Transmission LEDs blinks consistently about once/half second when this freeze happens, and there is no more HTTP reponse from the RESTduino. I have to hard reset the Arduino via unpowering it to get it to work again. Has anyone else had this problem when sending weird URL patterns?
When you use RESTduino and use pin 13, REST format address/13/1 does not work, as strtok extrack the correct '13' token but later only last significant character '3' is use for digitial port output.
Solution:
// select the pin
// int selectedPin = pin[0] -'0'; delete this line
int selectedPin = atoi (pin); // add this line
Serial.println(selectedPin);
Regards,
Agustin
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.