Show Posts
Pages: 1 ... 16 17 [18] 19 20 ... 67
256  Using Arduino / Interfacing w/ Software on the Computer / Re: A fatal error with Arduino and Python on: April 14, 2013, 07:14:35 am
Now I get it.  You want the Python program to reconnect to the Arduino when it's unplugged and then plugged back in.

I've never got unplug/replug detection working in Python.  It would go something like this: You'd need to detect the closing of the port (and the disappearing of its com port or device file), wait for its reappearance, and re-open it as you currently do.

You might get some coding ideas from this python network proxy I published on GitHub: https://github.com/billroy/serial-network-proxy/blob/master/bitty.py


-br

257  Using Arduino / Networking, Protocols, and Devices / Re: Network on: April 14, 2013, 06:30:55 am
Your Arduino code, acting as a client, can use HTTP GET and POST requests to fetch and update data on your external web site.

Your web server code can similarly use GET and POST requests to the Arduino to fetch and update data, once you configure your router to make it visible on the internet.

If you say a little more about what you're trying to accomplish, you might get better answers.

Good luck with your project,

-br

258  Using Arduino / General Electronics / Re: Do I need a resistor when connecting LED to digital output pin? on: April 13, 2013, 05:17:54 pm
… so use a resistor to limit the current to under 40 ma or you are likely to let the magic smoke out.

-br
259  Using Arduino / Networking, Protocols, and Devices / Re: is there a difference in sending a serial command at setup and during loop? on: April 13, 2013, 08:57:23 am
Because the Arduino is in reset and then the bootloader for a couple seconds after the serial.open, this won't work:

Code:
serialport = serial.Serial("/dev/ttyAMA0",115200);
serialport.write("^Power&\n");

This works better for me:
Code:
serialport = serial.Serial("/dev/ttyAMA0",115200)
time.sleep(2)
serialport.write("^Power&\n")

-br
260  Community / Bar Sport / Re: Debugging - a dark art? on: April 13, 2013, 07:41:01 am
"Learned helplessness":  A state of cultivated denial caused by the assumption that the problem is someone else's to solve.


-br
261  Community / Bar Sport / Re: Debugging - a dark art? on: April 13, 2013, 07:02:59 am
This is an important question that I think about a lot, and I'm glad you asked it.

I think the emotional aspects of debugging are often overlooked.  Discovering that the program you created is malfunctioning has an emotional dimension, right? 

Consider the five stages of a bug:

1. Shock
2. Denial
3. Anger
4. Bargaining
5. Acceptance

The helpless ones you are describing are stuck in shock/denial.  That is why it is so hard to direct their focus and attention.

The frustrated ones are stuck in the anger stage.  We've all been there.  Kind of hard to focus.

It's the ones who are past the anger and looking for answers/bargains that we can help with technical advice. 

In my view, people stuck in stages 1-3 actually need emotional / social support more than technical support, until they can get back to the state of mind required to articulate the problem and accept guidance to focus back on it so they can solve it themselves.

Would be interested in other thoughts on the matter.


-br
262  International / Software / Re: Salvare i commandi inviati via Serialport su una SD on: April 12, 2013, 07:12:45 am
Something like this:
Code:
#define BUFSIZE 15
case 2:
{
byte pos= 0;
char buffer[BUFSIZE];
buffer[0] = 0;
while (pos < BUFSIZE-1) {
if (Serial.available()) {
char c = Serial.read();
if ((c == '\n') || (c == '\r')) break;
buffer[pos++] = c;
buffer[pos] = 0;
}

Edit: Of course the VB program must be modified correspondingly to send a carriage return or line feed ascii character at the end of the command text.
263  International / Software / Re: Salvare i commandi inviati via Serialport su una SD on: April 12, 2013, 06:39:56 am
Please pardon my English.  This code has a bug of the type known as a "race condition":

Code:
  case 2:
if (Serial.available() > 0) {
byte pos= 0;
char buffer[15];
delay(10);
while (Serial.available() && pos < 15) {    // <-- race condition
buffer [pos++] = Serial.read();
}

After testing for the presence of any number of characters, the code attempts to read up to 15 characters.  If they have not all arrived in the serial input buffer by the time this code is first run, the code will exit prematurely, and fail to read the data and write it to the SD card.

A common solution is to have an "end of input" character, perhaps a carriage return ('/r' or '/n') to signal that all the input characters have been received so that this loop can be rewritten so the race condition won't happen.

Good luck with your project,

-br

264  Using Arduino / Programming Questions / Re: Quick question...can I call my setup() function? on: April 11, 2013, 10:22:37 am
I suppose it "should work" but it's kind of yucky.

Why not put the initialization you need to reuse into its own function and call it both from setup() and wherever else you need it?

-br
265  Using Arduino / Programming Questions / Re: Reading step/direction on: April 11, 2013, 08:25:53 am
Capture the step pulses with an interrupt.  In the interrupt routine, push the direction readings into a circular buffer.  In loop(), pull readings out of the circular buffer and perform the output action.

-br
266  Using Arduino / Programming Questions / Re: 'while' in setup(): what do I do wrong...? on: April 11, 2013, 07:01:39 am
If the button is wired right, the problem is in the code.  Could you post the whole sketch so we can be sure it isn't a small mistake in the part you haven't shown?

-br
267  Using Arduino / Interfacing w/ Software on the Computer / Re: Cocoa: IOKit: Freeze when trying to send a message on: April 11, 2013, 06:51:28 am
Well you might want to step through that last part in the XCode debugger to see where it leaves the tracks.

This looks suspicious:

Code:
int val = 255;
    write(serialFileDescriptor, val, 1);
    NSLog (@"after2");

Shouldn't there be a & in front of val in the write command?

Code:
    write(serialFileDescriptor, &val, 1);

-br
268  Using Arduino / Interfacing w/ Software on the Computer / Re: Easy way to Visualize and Store Serial Data on PC/Laptop? on: April 11, 2013, 06:47:41 am
Bitlash Commander might be worth a look, too:

https://github.com/billroy/bitlash-commander

-br
269  Using Arduino / Programming Questions / Re: 'while' in setup(): what do I do wrong...? on: April 11, 2013, 06:45:33 am
I don't see a problem with the code, except it could be shorter:

Code:
while (!digitalRead(button)) {;}
servo_1.write(180);

So I wonder if your button wiring is correct.  Do you have a pull-down resistor to force the pin to 0 when the button is not pressed?

-br
 
270  Using Arduino / Interfacing w/ Software on the Computer / Re: Library for sending/receiving data in UART Linux on: April 11, 2013, 06:40:59 am
Search for "serial communications in C"…  top hit looks potentially useful:

http://www.easysw.com/~mike/serial/serial.html

-br
Pages: 1 ... 16 17 [18] 19 20 ... 67