Giter VIP home page Giter VIP logo

Comments (8)

marcoschwartz avatar marcoschwartz commented on July 30, 2024

Thanks for letting me know! I'll have a look at your pull request.

from arest.

michaelsproul avatar michaelsproul commented on July 30, 2024

I ran into this too.

from arest.

marcoschwartz avatar marcoschwartz commented on July 30, 2024

I just tested that, it works just fine. I tried:

http://10.0.1.130/text?params=hallo

And the returned parameters is 'hallo'. Can you give more details like which hardware you are using? And also which Arduino IDE version? This way I can try to isolate the issue. Thanks!

from arest.

michaelsproul avatar michaelsproul commented on July 30, 2024

I'm running a Freetronics TwentyTen, which is Arduino Duemilanove compatible. I'm using a standard WizNet Ethernet 5100 shield and version 1.6.4 of the Arduino IDE (which is stable).

Here's a minimal example that shows the bug:

#include <SPI.h>
#include <Ethernet.h>
#include <aREST.h>

byte mac[] = { 0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF };

IPAddress ip(192,168,2,2);

EthernetServer server(80);

aREST rest = aREST();

void setup(void) {
  Serial.begin(9600);

  rest.set_id("001");
  rest.set_name("test");
  rest.function("print", printHandler);

  // Start the Ethernet connection and the server
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // Try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  server.begin();
  Serial.print("Server: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  EthernetClient client = server.available();
  rest.handle(client);
}

int printHandler(String command) {
  Serial.println("Message received:");
  Serial.println(command);
  return 0;
}

Here are some tests I ran using curl 7.42.0.

Here's the trailing HTTP/:

$ curl http://192.168.1.14/print?params=hello
{"return_value": 0, "id": "001", "name": "test", "connected": true}
Message received:
hello HTTP/

It seems that aRest just slices from the 7th character.

$ curl http://192.168.1.14/print?1234567
{"return_value": 0, "id": "001", "name": "test", "connected": true}
Message received:
 HTTP/

It's possible to get an entirely empty message by providing only 1 character in the query string:

$ curl http://192.168.1.14/print?1
{"return_value": 0, "id": "001", "name": "test", "connected": true}
Message received:

from arest.

marcoschwartz avatar marcoschwartz commented on July 30, 2024

Got it now ! It's just because according to the aREST documentation, you need to use ?params= before giving the arguments :) From the doc:

/led?params=0 executes the function

So you would need to do:

curl http://192.168.1.14/print?params=1234567

from arest.

michaelsproul avatar michaelsproul commented on July 30, 2024

@marcoschwartz: It's more than that, note the trailing HTTP/ in my first example. Also, requiring the string to be called params but not checking that strikes me as somewhat fragile (which is what my latter examples demonstrate).

from arest.

marcoschwartz avatar marcoschwartz commented on July 30, 2024

Hello,

I just tried again with my UNO + Ethernet shield, couldn't reproduce the trailing HTTP error. Can you try with the latest revision of the library ?

from arest.

marcoschwartz avatar marcoschwartz commented on July 30, 2024

This is now fixed :)

from arest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.