Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Programming Questions / Re: What is that error message : 1,0,0100,0,0,0 on: February 22, 2013, 01:09:08 pm
@james I don't see how that is helpful. If you actually looked at most of those links you would notice documentation of the third field of this status response is unclear.

@pierr 0100 is undocumented. I cannot find it anywhere. Here is my post on sparkfun about this:
https://forum.sparkfun.com/viewtopic.php?t=34706&user_select=45522

I even commented on the actual product asking. I've also emailed the manafacturer.

No one knows.

From my experience 0100 means that the PDP context hasn't fully initialized. It is important to ensure you get an OK before you supply it with further commands.

the 0 in your response means socket is not connected. Just look at it and hope for a 1.
2  Using Arduino / Programming Questions / Re: Concatenate Float w/ a String on: February 20, 2013, 01:40:36 am
I did this the moment I saw it krup. Many thanks for the github link though. I find it more reliable than your site smiley
3  Using Arduino / Programming Questions / Re: Concatenate Float w/ a String on: February 19, 2013, 08:10:35 pm
Quote
I tend to avoid doing floating point calculations in my projects, so I have no need to enable it. If enough people care about this lack of option and complain to the developers that it should be included, I'm not going to argue against it.

That is fair smiley. So let's get it as a valid option smiley-grin!
4  Using Arduino / Project Guidance / Re: Do arduino uno shields fit into the Arduino Mega on: February 18, 2013, 11:51:07 pm
Yes they will fit.

Compatibility however is more complicated. You will have to check the schematics of both to ensure that the Arduino pins they rely on do the same things on the mega and the uno.

This is particularly a problem with SPI interfaces. Otherwise I think you should be ok.
5  Using Arduino / Project Guidance / Re: Hardware Serial Buffer with multiple High Speed Devices on: February 18, 2013, 11:47:54 pm
Thanks for the link, I applied the fix which Nick suggested. Although I have a feeling you are going to moan at me about that smiley-razz.

As for the state machine, I'll give that a try tomorrow smiley


6  Using Arduino / Project Guidance / Re: Hardware Serial Buffer with multiple High Speed Devices on: February 18, 2013, 10:43:01 pm
@Spatula:
I'll have a play with realterm smiley.

waitFor is not called from GPS loop. GPS loop grabs the current coords if available and chucks them into a kalman filter. As it uses tinyGPS it has something similar to my readAtString.

Speaking of waitFor:
Code:
void waitForOK() {
  at_buffer = "";
  while(true)
  {
    if(Serial3.available()>0) {
      if(readATString(Serial3.read())) {
        break;
      }
    }
  }
  at_buffer.trim();
  if(at_buffer.compareTo("OK") == 0) {
    Serial.println("Found OK");
    return;
  } else {
      if(at_buffer.length() > 2) {
        // |'s denoting i cant actually process the stuff atm
        Serial.print('|');
        Serial.print(at_buffer);
        Serial.println('|');
        return;
     }
     waitForOK();
  }
}

Seems to work a lot better and was an obvious change after reading: http://gammon.com.au/serial

It now waits for a single line of characters that is longer than 2 or "OK" before relinquishing its grasp.

Still dropping random characters though smiley-sad

@PeterH:

I believe the above may please your issues with my waitForOk. I no longer have any delays in the code.

I am unable to post my full code as it is part of a project whose Intellectual Property does not soley reside with me. I understand how this makes things difficult but I am not privy to post the exact method in which im transmitting data or storing it on removable media. I am looking more for theoretical answers if possible which largely your post is smiley

Could you provide a reference for your String class issue. It is on the official reference documentation and as such I thought it would be ok to use. With your reference I'll be able to evaluate things and hop to char arrays ok?

I understand that you guys all get silly questions all day but could you please try to not come across as hostile. Being firm is fine, i've already re-written waitForOK twice simply from being embarrassed at everyone pointing out it's flaws. Spatula's approach is fine PeterH I found you slightly rude. Sorry smiley-sad. I understand if that last sentence might piss you off and you might not want to continue helping. I am however grateful that you are providing new insight the state machine idea is fantastic.

Just so I understand the concept is this approach the sort of thing you had in mind:
Send a command that needs an OK
Switch to a state that solely listens for an OK and doesn't process anything else
Receive an OK and go back to the PROCESS ANYTHING state.

The problem with that is how to handle sequencing. Say the following needs to happen:
A
OK
B
OK
C
OK

When in the OK state and i get OK how do I know which command to send next? What comes to mind is a FIFO data structure? Would this work?
7  Using Arduino / Project Guidance / Re: Hardware Serial Buffer with multiple High Speed Devices on: February 18, 2013, 09:38:11 pm
Thanks for your response,

I'm aware of the problems with the code and am constantly working to improve them. This however is not the subject of this topic so while your critique is valued and will be used to improve said code I was looking more for something that may be causing the problem other than my unoptimized code. I'll make your suggested changes and try again though smiley

I am trying to determine what might be cause my character drop on Serial2. As explained(maybe poorly) without a delay() or a serial print waitForOK fails to do anything. It is like a shrodinger's cat problem. I do believe a 64 byte buffer is able to store an OK for half a second. I have removed the delay and will be more patient with waitForOK()(see below).

On the subject of the String object. I fail to see how its a problem granted it uses more memory but I have plenty to spare I like the functionality of String for rapid development. If memory becomes an issue I will be able to downgrade to char arrays which I hate but put up with smiley

On the subject of waitForOK I expect OK, If i do not get it the rest of the sketch is unlikely to work. At this stage in development If i get anything other than OK im just printing it. I then workout what went wrong and rerun the code.

However due to the vanishing character issue im getting "O" and "K" or sometimes just " ".

I can remove the recursion when i reliably get either OK or CME ERROR. It is just being reset when it deadlocks as the realterm output clearly recieves OKs Netherless:
Code:
void waitForOK() {
  //Without a println or a small delay here I never seem to get an "OK"
  //Serial.println("Waiting for OK");
  delay(5);
  at_buffer = "";
  while(Serial3.available() > 0)
  {
    if(readATString(Serial3.read())) {
      break;
    }
  }
  at_buffer.trim();
  if(at_buffer.compareTo("OK") == 0) {
    Serial.println("Found OK");
    return;
  } else {
      if(at_buffer.length() > 2) {
        Serial.println(at_buffer);
        return;
     }
     waitForOK();
  }
}
Should solve that problem while maintaining the behaviour i want for now. trim removes the whitespace if whats left is longer than "OK" then its likely to be a CME ERROR.

Quote
It's just a CR, isn't it?

If you look at my output image you'll see a CRLF on a seperate line after an actual command. The whitespace before this appears to match the length of the string on the line before. This does not occur with the GPS data or anything else i've seen through serial.
8  Using Arduino / Project Guidance / Re: Hardware Serial Buffer with multiple High Speed Devices on: February 18, 2013, 08:45:15 pm
Thanks for your responses from them I'm guessing my waitForOK is the problem. Most AT commands respond with just OK and the order of my command sequence needs to be maintained so that the module is ready for what I want to do with it. For example here I have some captured output from the snoopping wire into realterm:

I believe the whitespace line acts as a kind of checksum based entirely on the length of the previous line. But it is rather irritating as it interferes with waitForOK further.

 It behaves strangely if I don't perform a small action before reading from serial3 within it. I used to have this as a Serial print which made debugging impossible. I settled for a short delay instead.


Ill post relevant areas of code but am unable to post the full code:

at_buffer is a String object
Code:
void loop () {
  if(Serial3.available() >0) {
    if(readATString(Serial3.read())) {
      processATString();
    }
  }
  if(Serial2.available() > 0) {
    gpsLoop();
  }
}
boolean readATString(char c) {
  if (c == -1) {
    return true;
  }
  if (c == '\n') {
    return true;
  }
  if (c == '\r') {
    return false;
  }
  at_buffer += c;
  return false;
}
void waitForOK() {
  //Without a println or a small delay here I never seem to get an "OK"
  //Serial.println("Waiting for OK");
  delay(500);
  at_buffer = "";
  while(Serial3.available() > 0)
  {
    if(readATString(Serial3.read())) {
      break;
    }
  }
  at_buffer.trim();
  if(at_buffer.compareTo("OK") == 0) {
    Serial.println("Found OK");
    return;
  } else {
      if(at_buffer.length() > 2) {
        Serial.println(at_buffer);
     }
     waitForOK();
  }
}

Is it the case that ANY blocking part of code will cause this character disappearance?
9  Using Arduino / Programming Questions / Re: Trying to learn how to code Sketches on: February 18, 2013, 08:32:27 pm
I think the word sketch has something to do with the way the code is used on the device. I too dislike its usage though.
10  Using Arduino / Programming Questions / Re: Concatenate Float w/ a String on: February 18, 2013, 08:31:17 pm
If were talking about a project that could do with a 1280 I don't know why we are comparing it to the price of a tiny with a lot less processing power that will probably fall short anyway. Regardless. Its still my choice to throw money around and have enough power to throw floats around. I think that solves the money problem.

Your Kludge is a kludge.
Quote
A kludge (or kluge) is a workaround, a quick-and-dirty solution, a clumsy, inelegant, difficult to extend, hard to maintain yet effective and quick solution to a problem, and a rough synonym to the terms "jury rig", "Jugaad" or "jerry rig".

which leads me to backwards learning, I mean if someone sees your kludge and they aren't aware of the lack of float support they will most likely come to your desk and ask you what is going on. Instead you could enable floating support because your platform obviously needs it if you are writing that code.

Without wanting to flog a dead horse here i'll make it brief, The option to enable floats should be a part of the arduino core. Do you have any arguments to just that sentence that make it not being an option logical?
11  Using Arduino / Programming Questions / Re: Trying to learn how to code Sketches on: February 18, 2013, 08:15:13 pm
Hi there, You initialize variables outside of setup() when you want them to be global. That is available to all parts of your sketch. You can then use them in setup to perform steps BEFORE the main loop.

it is
Code:
//Visible everywhere GLOBAL
int a = 1;
int b = 2;
int c = 0;

void setup() {
//Accessing GLOBAL variables inside setup
c = a+b;

//A LOCAL variable
int d = b-a;
}

void loop() {
  // c = a * d; This will error because d does not exist outside of setup it is LOCAL to setup.
  c = a * b; //This is fine because a,b and c are GLOBAL
}
12  Using Arduino / Project Guidance / Hardware Serial Buffer with multiple High Speed Devices on: February 18, 2013, 07:58:50 pm
Hi,

Got an Arduino Mega with 2 Serial devices connected to HardwareSerial pins:
A 10hz GPS Module(Lycos LS20031)
A Cellular Module (The ever so popular but cryptic SM5100B).

A sketch talks to both of them and sometimes works. After like 12 hours of debugging I have narrowed the problem down.

When the GPS module has a fix it screams 10hz data into Serial 3. At the same time im processing cellular AT commands in Serial2.

Occasionally Serial2 will appear to lose random characters from an AT command response. For example SOCKSTATUS has appeared as SCKSTATUS and SOCKSTATU etc. This becomes a particular problem when trying to send data. It requires an initiating command which is acknowledged by a ">" which signifies that I can start sending data. Serial2 Routinely misses this ">" which hangs my processing as my recovery commands are interpreted to be a part of the outgoing data.

I have snooped on Serial2 Using a FTDI to USB board and have verified that the cellular module does in fact send the ">" and correctly sends "SOCKSTATUS" reliably.

I noticed this problem before with SoftwareSerial and the GPS data which was fixed by increasing the SoftwareSerial buffer. Hoping this would do the same I proceded to edit HarwareSerial.cpp(57,60) to up the buffer size to:
Code:
#if (RAMEND < 1000)
  #define SERIAL_BUFFER_SIZE 256
#else
  //#define SERIAL_BUFFER_SIZE 64
  #define SERIAL_BUFFER_SIZE 512
#endif

This seems to have worsened the problem as now the module startup sequence is being missed. Reading the rest of the code I noted that this gives essentially 4 serial ports 512 bytes of memory so reduced it again to a lower value.

Is there anything I can do to increase the reliability of getting the entire message through? Or do I have to slowdown my GPS.

I am unable to see if this is a problem on the GPS module. Its data is so fast that any lost data is usually not missed by my code.
13  Using Arduino / Programming Questions / Re: Concatenate Float w/ a String on: February 18, 2013, 07:32:29 pm
Quote
... And more expensive. Not every project needs a $10 micro-controller, especially if I can spend ~$1 on an ATTiny and accomplish what I need to with a simple "kludge"
I understand the cost point here but that isnt the problem. Thats why I love arduino's compatibility features with several different micro-controllers. The point here is I spent the money on a mega why am I not allowed to use floats naturally without an ugly kludge or including some third party modifications?

It should be a documented step to enable, or like the very nice edit a checkbox. I would uncheck that box when working with tinys or unos.

Quote
it wouldn't make much sense to spend 10x the amount on the chip for additional software support that can be handled with a "kludge" like this

10x? Really? The mega cost me just under double the price of the uno. I'm not sure about the actual controller but if i was a large company and buying in bulk this wouldn't come close to 10x the cost. Again I don't see why I'm not allowed to make the decision to have floats.

Kludges are a problem. I expect a C++ programmer to be able to pickup an Arduino sketch and have a go. Suddenly they see some weird code which needs to be included either once(A function) or every time a float is used. This leads to backwards learning.

Quote
Sure. But take a look at the Arduino-specific functions, like digitalRead() and analogRead(). What types do those functions return? What about millis()? micros()? Can you find a single Arduino-specific function that returns a float?

Allow me to quote the arduino home page:
Quote
Arduino can sense the environment by receiving input from a variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators.

How many sensors are you aware of that output floats? GPS,Accelerometers,Gyros, I even saw a geiger counter shield.

I get what you are saying, I guess the point here is. I want the option to enable them and disable them at will. Most of the time its disabled.

Something else from the main website:
Quote
Simple, clear programming environment - The Arduino programming environment is easy-to-use for beginners, yet flexible enough for advanced users to take advantage of as well.

Well I want to as what i would consider myself to be( an advanced user) want take advantage of floats in sprintf and thanks to a third party I can. smiley
14  Using Arduino / Programming Questions / Re: Concatenate Float w/ a String on: February 17, 2013, 10:19:40 pm
What you said makes sense, except that limitation does not exist if they use up to date hardware. The mega came out ages ago then there was the mega 2560. Now we have the DUE.

Seeing as the overall goal of Arduino is to create prototype systems that may warrant actual development I don't see why the additional detail in data(i mean floating point data) availability should be limited.

%f is a lot more intuitive and usable then the horrible kludges I read. Isn't this meant to be an easy to use platform?
15  Using Arduino / Networking, Protocols, and Devices / Re: Arduino mega 2560+ GPRS shield + CAN-Bus shield problem on: February 17, 2013, 10:15:11 pm
You need to follow Pauls suggestions.

He gave you everything you needed.
Pages: [1] 2 3 4