Show Posts
Pages: 1 ... 26 27 [28] 29 30
406  Using Arduino / Networking, Protocols, and Devices / Re: Check for Ethernet/Internet connection & re-establish if lost? on: February 16, 2013, 11:57:16 am
You can look (in this forum as well) for implementations of ICMP ping. Then you can periodically ping your router and try to reconnect if you get no answer. Ethernet.maintain() seems a good choice. A GET request to a web server can also do the job, but it takes longer and is a less reliable indicator of a local network problem.
407  Topics / Home Automation and Networked Objects / Re: Simple arduino ethernet communication for beginner on: February 15, 2013, 11:33:37 pm
POST and GET belong to the HTTP protocol on top of TCP. The Ethernet library provides TCP. People usually write code to implement some minimal HTTP support, but this rarely gets beyond answering GET requests (which are of mime type text). POST requests have mime type multipart/form-data. They are more difficult to parse, and I doubt that the limited memory the Arduino can do a good job. But I can't see why one would want to send POST requests to the Arduino server, instead of using GET. You send a request:

GET /whatever/since/its/a/fake/webserver?param1=value1&param2=value2 HTTP1/0

Then it's up to your code to parse the string to extract the query string (the part beginning with ?), the parameters and their values. You should return some response to the client (e.g., "200 OK" followed by some text or HTML). There are many examples around, but they are always specific to a certain problem because you cannot implement the entire HTTP protocol. If you only want to set a PIN to HIGH or LOW you can even dispense with the query-string part and use "clean URLs" (sort-of):

GET /pin/1/LOW
GET /pin/2/HIGH

Then use your preferred method to locate a string within a string (strstr, strcmp, sscanf), apply the values, and you're done.
408  Using Arduino / Programming Questions / Re: indexOf does not work with a string value? on: February 15, 2013, 10:51:28 pm
In the "time" case you were lucky to copy the remainder of the original string, starting from position 'a' and terminated by a null char. Not so with "page". As a quick and dirty solution you can initialize temp2 with zeroes, or append a null char after the copy, but if you don't take into account the length of the query string and the position of your keyword into it you are going to waste memory.
409  Using Arduino / Programming Questions / Re: indexOf does not work with a string value? on: February 15, 2013, 08:02:26 pm
substr() is a C++ <string> method. Any other options?
The c equivalent of a string is an array of char, so when you know the start and end position of the "substring" within the larger one you can just copy the array elements into a new array. Or if you need to make a comparison you may use the 'n' variant (strncmp) which compares two strings up to a certain number of characters.

I very much like the solution based on regular expressions. Mine, however, is the opposite. I see you are trying to parse the parameters of a query string. Your problem is quite specific and a less generic solution may work better in your case. Consider a loop on each character of the string.

Start by locating the '?' sign, i.e. the beginning of the query string, then:
1. save the current position (+1) into a variable (e.g., name_start). From that position, start looking for the first '=' sign. The array between name_start and the position of '=' is the parameter name.
2. save the current position (+1) into a variable (e.g., value_start). From that position, start looking for the first '&' sign or space.
The array between value_start and the position of '&' or space is the parameter value.
3. If you found a space exit the loop, otherwise repeat from 1.

You could then make improvements to make it more robust, e.g.: manage the premature end of the query string, manage spaces or url-encoded characters, but this should give you a start.
410  Using Arduino / Programming Questions / Re: Arduino Ethernet Help on: February 15, 2013, 04:00:29 pm
You may also consider a PoE injector cable - you feed it with ethernet and power from different sources and it "merges" them into a single ethernet cable. Here is an example (I've never used it and not endorsing it, it's just to give you an idea). Note that they call it "splitter" while it is actually two cables, an injector and a splitter. What you need is the PoE injector function.
411  Using Arduino / Project Guidance / Re: Clean and energy efficient LED dimming on: February 14, 2013, 11:26:14 pm
I'm no expert, but since MR16 lamps are designed to be compatible with halogen lamps their internal circuitry, by design, has to work in concert with transformers and dimmers made for halogen lamps. This compatibility requirement has led to proprietary solutions which may have important side-effects.

I'm not sure whether the source can be considered reliable, but here's a couple of articles that worried me and
412  Using Arduino / Programming Questions / Re: Simple problem with floating program on: February 13, 2013, 08:56:39 pm
You defined almostEqual() within loop(); you need to move the definition outside loop(). Just move one of the closing curly braces a few lines up and it should compile.
413  Using Arduino / Programming Questions / Re: Serial communication with java on: February 13, 2013, 06:18:02 pm
I would start from the Arduino part: if you upload the program from the IDE and open the serial monitor (in the Tools menu), do you see the message "Is there anybody out there?"

I assume that the values in the preferences file are ok, i.e. serial.port corresponds to the name of a serial port you can see in your system's resources (and in Arduino IDE), and serial.debug_rate is 9600. Can you confirm that?

One possible reason you don't get messages from the Java application is that you are running the program while the Arduino IDE is still running: the IDE is using the serial port and the Java application cannot access it. You may try and close the Arduino IDE after uploading the program (but leaving the USB connected) also check that there is no avrdude process running in background, then start the Java application.

If unsuccessful, can you change the Java code to inspect the properties of 'port' after this line of code is executed?

SerialPort port = (SerialPort)"serial talk", 4000);

I don't know the class, but perhaps there are methods in SerialPort that can check whether the port is actually open.

Please remember to enclose any code you post within code blocks.
414  Using Arduino / Installation & Troubleshooting / Re: Arduino for Mac - avr-gcc: : No such file or directory on: February 13, 2013, 05:46:10 pm
Have a look at this discussion:,147573.0.html and see if something applies to your case (ignore the part about Wiring). If not, you should provide more detailed information about your environment (OS version, IDE version), and post a full log of the error (hint: show verbose output in Arduino preferences).

Good luck!
415  Using Arduino / Programming Questions / Re: Help with GET request? on: February 13, 2013, 05:48:55 am
Ethernet.begin(mac, subnet, gateway);

Wrong order of parameters, missing dns.
416  Using Arduino / Installation & Troubleshooting / Re: A beginner's question: arduino with mac os x 10.8.2 can't upload on: February 13, 2013, 05:24:00 am
  • In the Arduino IDE (programming application) open the sample blink application.
  • Open the Preferences window (menu Arduino -> Preferences). Tick both options near "show verbose output during:": both for compilation and upload. Confirm with Ok button.
  • Try to upload your program (either press the right arrow button in the program's window or choose menu File -> Upload).
  • Select and copy the log text appearing in the window below the program editor.
  • Paste what you have copied into a new reply to this post.

When you write your reply, remember to enclose the log within a code block. A code block can be created by pressing the # button in the menu above, look at smiley smiley-wink. It starts with "code" and ends with "/code" enclosed in squared brackets. Here is an example, with an extra space that should not be there, but prevents its being formatted:

[ code]
Your log goes here...
[ /code]

If you remove the spaces, after you post your reply it will be shown as

Your log goes here...
417  Using Arduino / Programming Questions / Re: Help with GET request? on: February 12, 2013, 09:50:13 pm
Eh, not interested. I just want to know why the current code doesn't work.

Fine. I took the liberty of modifying my original suggestion because it was wrong.

Perhaps you might be more interested in persistent connections under HTTP/1.0.
418  Using Arduino / Programming Questions / Re: Help with GET request? on: February 12, 2013, 08:12:32 pm
Are you using a proxy?

If you can get nc (or netcat) working on your system you can echo the messages sent to a local port, e.g.

nc -l 8000

[edit] Then change your parameters to connect to localhost your system's IP address port 8000 and see what happens.
419  Using Arduino / Project Guidance / Re: Newbie question - How to monitor open/closed state of two relays?? on: February 12, 2013, 07:47:52 pm
It almost seems that I could use this:

This is even simpler

Since you are not drawing any current from the circuit I don't see why in principle it shouldn't work using three wires (2 inputs, 1 ground), but as already pointed out it depends on the length (resistance) of the wires. As for monitoring two relays you can just connect them to two different digital inputs (two pinMode() calls in the setup, two digitalRead() calls in the loop).

A true Arduino geek would probably think of something more creative: Xbee, infrared, laser beams... but a wired solution can be tested really quick.
420  Using Arduino / Installation & Troubleshooting / Re: Arduino Uno Rev3 not recognized on: February 12, 2013, 05:21:19 pm
it shows up in the device manager as "Quest Software USB Device".

Isn't Quest software related to virtualization? Maybe you should try to disable USB virtualization.
Pages: 1 ... 26 27 [28] 29 30