Show Posts
Pages: [1] 2 3
1  Development / Other Software Development / Re: Windows/Linux/Mac Eclipse plugin to compile and upload arduino sketches on: August 09, 2013, 05:13:03 pm
Installation Instructions... Just reinstalled Eclipse to keep Arduino separate from other environments.  Using Eclipse Kepler (Ubuntu 13.04, AMD64), got confused by the installation instructions.  Using .../update site/ found there are two entries: 'Arduino' and 'Uncategorized'.  Following instructions tried to install 1.2.0 and got a heap of error messages.  Looked under 'Uncategorized' and found version 1.2.4 which seems to install OK.
The installation instructions referenced from the home page give different details from the sticky in this topic, and neither work.  It would be very helpful if they could be changed to reflect what one actually has to do, or .../update site/ be changed to match the instructions.
Which is not to detract from my admiration for a fine piece of technology: thank you Jantje.
2  Using Arduino / Networking, Protocols, and Devices / Re: UDP fails, sometimes on: November 17, 2012, 01:55:43 am
The NTP servers use UDP, so TCP is not an option.  However, it might help to increase the UDP buffer size to 48 bytes or more so that it doesn't have to send a second packet and then get stuck.  I'll have a go the next time I'm reworking the code.
3  Using Arduino / Networking, Protocols, and Devices / Re: UDP fails, sometimes on: November 14, 2012, 01:31:10 pm
Since it definitely is not on the local net (eg, 192.168.0.xxx) then it should go into the router.  And the library should not hang.  But it does seem that way to happen that way.  Puzzling.
4  Using Arduino / Networking, Protocols, and Devices / Re: UDP fails, sometimes on: November 14, 2012, 12:18:43 pm
Thanks Tim, this is beginning to sound more interesting.  The packet size is 48 bytes (standard for NTP request?) and so the buffer (32 bytes ??) could be full and the library code could well be trying to execute a write.  The destination is one of the NTP servers, not sure which one because it is chosen on a round robin basis from a list of about 30.  It could well be the problem arises because the server is offline (or mistyped in my list).  But does the library really fail if it is given a bad IP address ?  I could not find a way of checking that an address is correct before using it.
My code was modelled from example 15.14 in Arduino Cookbook, ISBN 978-1-449-31387-6, by the way.
5  Using Arduino / Project Guidance / Interface with Raspberry Pi on: November 14, 2012, 06:44:45 am
It looks like the Raspberry Pi and the Arduino complement each other very well.  Has anyone defined the 'best' way to connect the two ?  Is there scope for a topic in the Playground ?
6  Using Arduino / Networking, Protocols, and Devices / Re: UDP fails, sometimes on: November 14, 2012, 06:31:33 am
Thanks for the comment.  I know about UDP not having 'assured delivery' but my problem is slightly different.  And that is what is puzzling me.  I've got code (not shown) to check for failure to receive a reply packet, but what seems to be happening is that the write itself stalls.  I've put trace Serial.println() between each line and it seems like it never gets to the call to endPacket.  Hence my confusion.
7  Using Arduino / Networking, Protocols, and Devices / UDP fails, sometimes on: November 12, 2012, 07:18:29 am
The code is hardly worth listing:
Code:
    udpipe->beginPacket(IPAddress(a,b,c,d),port);
    udpipe->write(buffer,PACKET_SIZE);
    udpipe->endPacket();
It *seems* like this works for some (NTP server) addresses but stalls during udp.write() for other addresses.  I can't imagine how this could be.  If it is due to the server I'm trying being offline (or incorrectly addressed: finger trouble is always possible), then how can one check whether there is a problem: there don't seem to be any useful return codes for these functions.  I've got the sketch working fine at the moment using one NTP server but don't know whether it is just that I'm using a good luck.
Ideas anyone ?
8  Using Arduino / Programming Questions / Re: Ethernet & SD - SD working once. on: November 12, 2012, 07:04:31 am
Just thought I'd add a note.  Found the problem.  The real cause was a damaged pointer (isn't that always the problem in C), but it was hidden by the buffering in Serial.print().  Found it eventually by putting in some delays to allow the Serial buffer to flush so I could spot where the real problem was.  Lesson for me is to make allowances for timing when doing debugging.
9  Using Arduino / Programming Questions / Re: Ethernet & SD - SD working once. on: October 12, 2012, 05:24:46 am
I've had a go with this approach and it seems to work in a simple case, but I still have a problem with the actual program I'm writing (rather than a simple exercise to try to identify what is going on).  The symptom I get is that shortly after doing an EthernetServer.begin() I get what appears to be a reboot: in the middle of a Serial.println() just after the begin() call, the 'printing' is interrupted and my setup() restarts.
I'm working on producing something simple that consistently reproduces the problem, but in the mean time, can someone more knowledgeable than me advise...
1) exactly how the ethernet library knows which are MOSI, MISO, SCK and SS ... because it seems to use the system defaults for MOSI, MISO and SCK, but always pin 10 for SS
2) if it is possible that both the SD library and the Ethernet library can be grabbing MOSI, etc, at the same time 'behind the scenes'... or do they only operate when I specifically call them, in which case I can make sure the other one is disabled
3) which way round is SS enable/disable: enable=LOW, disable=HIGH ?
4)  why pin 53 (the default SS on the Mega) should be set to OUTPUT even if it isn't connected to anything (mentioned in a different thread) and whether it matters if it is set to HIGH of LOW
5)  how the xmit() function, copying from SD file to Enet client, works at all (and it does, trust me) unless the two libraries are careful about selecting the SPI bus at the byte by byte level
And, of course, finally, where (if?) there is some comprehensive documentation so I don't have to clutter this thread with dumb questions.
10  Using Arduino / Networking, Protocols, and Devices / Re: Client IP address using Ethernet library on: October 12, 2012, 02:01:11 am
Thanks for pointing me at that thread ZoomKat... I searched but did not find it.  PaulS: security of course.
11  Using Arduino / Networking, Protocols, and Devices / Client IP address using Ethernet library on: October 11, 2012, 06:32:53 pm
I can get the Ethernet library to serve pages OK, but it would be nice to be able to determine the Client IP address.  Since most users will connect through various NAT boxes, the address that the browser sees (eg 192.168.0.27) is obviously not the useful one.  There are lots of ideas on the interweb about how to use google, server side PHP, etc, etc, but none that would be much use to an Arduino.  Has anyone solved this problem?
I'm sending a bunch of Javascript to format the page actually displayed, so including a bit more to get the research executed at the client end would be one possibility.
12  Using Arduino / Programming Questions / Re: Ethernet & SD - SD working once. on: October 11, 2012, 05:56:08 pm
I think (but am not at all sure) that I am getting a similar problem... here is my code, with the results from some tests as comments near the front
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
EthernetServer* server;
typedef unsigned char byte;
typedef unsigned char* addr;
#define BZ 250
byte buffer[BZ+1];
/*

on reload...
starting ethernet
bytes loaded 0
starting server
setup done

on reset...
starting ethernet
bytes loaded 0
starting server
setup done

on reload...
starting ethernet
bytes loaded 24
starting server
setup done
client started
GET / HTTP/1.1
Host:
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,#/#;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cache-Control: max-age=0
bytes xmit 12481

on reset...
starting ethernet
bytes loaded 24
starting server
setup done

*/

short load(byte id) {
  char fn[] = "@.BIN";
  fn[0] = '@' + id;
  File istream = SD.open(fn,FILE_READ);
  short sz = BZ;
  if(istream) {
    addr to = &buffer[0];
    memset(to,0,sz);
    short d = istream.read();
    while(sz && d != -1) {
      *to = d;
      ++to;
      --sz;
      d = istream.read();
    }
    istream.close();
  }
  return BZ - sz;
}

short xmit(EthernetClient ostream, byte fid) {
  char fname[8] = "*.TXT";
  fname[0] = fid;
  File istream = SD.open(fname,FILE_READ);
  short sz = 0;
  if(istream) {
    byte data = istream.read();
    while(data != 0xFF) {
      ++sz;
      if(ostream)
        ostream.print((char)data);
      data = istream.read();
    }
    istream.close();
  }
  return sz;
}

void setup() {
  Serial.begin(9600);
  unsigned char mac[] = // hidden for security reasons
  unsigned char addr[] = // hidden for security reasons
  unsigned char gate[] = // hidden for security reasons
  unsigned char dnsa[] = // hidden for security reasons
  unsigned char dnsb[] = // hidden for security reasons
  unsigned char mask[] = {255,255,255,  0};
  pinMode(11,INPUT);
  pinMode(12,INPUT);
  pinMode(13,INPUT);
  SD.begin(4); // to use onboard SD card reader
  Serial.println("starting ethernet");
  Ethernet.begin(mac,addr,dnsa,gate,mask);
  delay(1000);
  Serial.print("bytes loaded ");
  Serial.println(load(1));
  Serial.println("starting server");
  server = new EthernetServer(80);
  server->begin();
  Serial.println("setup done");
}
void loop() {
  EthernetClient client = server->available();
  if(client) {
    Serial.println("client started");
    while(client.available()) {
      char c = client.read();
      Serial.print(c);
    }
    short sz = 0;
    sz += xmit(client,'H');
    sz += xmit(client,'1');
    sz += xmit(client,'C');
    sz += xmit(client,'2');
    sz += xmit(client,'J');
    sz += xmit(client,'3');
    char* t = "elves[CLOCK].C = new Date();";
    client.println(t); sz += strlen(t);
    t = "sPage();";
    client.println(t); sz += strlen(t);
    sz += xmit(client,'4');
    Serial.print("bytes xmit ");
    Serial.println(sz);
    delay(10);
    client.stop();
  }
}
I am using a Mega2560 with the standard(?) Ethernet card with the microSD reader built in and have jumpered:
Mega pin 50 to card pin 12
Mega pin 51 to card pin 11
Mega pin 52 to card pin 13

My symptom is pure intermittent: sometimes it works and sometimes it doesn't, with no determinable set of conditions to indicate which.  Given the above comments, I'll try fiddling with pin 10 and see whether the symptom goes away... difficult to distinguish between 'fixed' and 'less frequent' in this sort of case.
13  Using Arduino / Storage / Re: Moving SPI pins ? on: October 09, 2012, 01:45:30 am
Just to conclude and pass on a hint.  Eventually got around to testing this approach with a standard Ethernet card on an Arduino Mega and found the following works...

jumpers...
Mega pin 50 to card pin 12
Mega pin 51 to card pin 11
Mega pin 52 to card pin 13

setup() { ...
pinMode(11,INPUT);
pinMode(12,INPUT);
pinMode(13,INPUT);
SD.begin(4);
Ethernet.begin(...

I expect the same would work for the card I mentioned.

14  Using Arduino / Programming Questions / Re: Conditional compilation fails on: October 09, 2012, 01:38:37 am
I think the point I made is proved, but the terms I used were obviously confusing.  Simply viewed, 'compilation' is everything that happens after I press the 'compile' button in the IDE.  And it is buggy, as discussed above.
15  Using Arduino / Programming Questions / Re: Conditional compilation fails on: October 08, 2012, 05:05:03 am
OK, PaulS... this is what you wanted...  don't blame me for the size of the post...
Code:
#include <EEPROM.h>
#undef INIT
#define EPROM 1024

#define USECHAR
#ifdef USECHAR
#define TYPE char
#else
#define TYPE long
#endif

#define USECONST
#ifdef USECONST
const TYPE KEYA =  1;   
#else
#define KEYA ((TYPE) 1)   
#endif
boolean v;

int freeRam() {
  extern int __bss_end; // == extern unsigned int __heap_start;
  extern void * __brkval;
  int freememory;
  freememory = ((int)&freememory) - (((int)__brkval == 0)? ((int)&__bss_end): ((int)__brkval));
  return freememory;
}
unsigned long sketchSize(void) {
  extern int _etext;
  extern int _edata;
  return ((unsigned long)(&_etext) + ((unsigned long)(&_edata) - 256L));
}
void setup() {
  Serial.begin(9600);
  TYPE tt = random();
  boolean w = true;
  v = tt == KEYA;
  w = w && v;
  Serial.print("using ");
  #ifdef USECHAR
  Serial.print("char ");
  #else
  Serial.print("long ");
  #endif
  #ifdef USECONST
  Serial.print("constants");
  #else
  Serial.print("definitions");
  #endif
  Serial.print(", sketchsize "); Serial.print(sketchSize());
  Serial.print(", freeram ");Serial.println(freeRam());
  Serial.println(w);
}

void loop() {
  ;
}

This generates the following compiler output...
Code:
avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -I/usr/share/arduino/libraries/EEPROM /tmp/build3179014252548270902.tmp/eepromtest.cpp -o /tmp/build3179014252548270902.tmp/eepromtest.cpp.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/EEPROM/EEPROM.cpp.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/wiring_pulse.c.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/wiring_analog.c.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/WInterrupts.c.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/wiring_digital.c.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/wiring.c.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/wiring_shift.c.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/HID.cpp.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/WString.cpp.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/main.cpp.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/Stream.cpp.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/Tone.cpp.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/HardwareSerial.cpp.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/Print.cpp.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/IPAddress.cpp.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/new.cpp.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/CDC.cpp.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/WMath.cpp.o
  Using previously compiled: /tmp/build3179014252548270902.tmp/USBCore.cpp.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/wiring_pulse.c.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/wiring_analog.c.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/WInterrupts.c.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/wiring_digital.c.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/wiring.c.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/wiring_shift.c.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/HID.cpp.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/WString.cpp.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/main.cpp.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/Stream.cpp.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/Tone.cpp.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/HardwareSerial.cpp.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/Print.cpp.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/IPAddress.cpp.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/new.cpp.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/CDC.cpp.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/WMath.cpp.o
avr-ar rcs /tmp/build3179014252548270902.tmp/core.a /tmp/build3179014252548270902.tmp/USBCore.cpp.o
avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o /tmp/build3179014252548270902.tmp/eepromtest.cpp.elf /tmp/build3179014252548270902.tmp/eepromtest.cpp.o /tmp/build3179014252548270902.tmp/EEPROM/EEPROM.cpp.o /tmp/build3179014252548270902.tmp/core.a -L/tmp/build3179014252548270902.tmp -lm
avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/build3179014252548270902.tmp/eepromtest.cpp.elf /tmp/build3179014252548270902.tmp/eepromtest.cpp.eep
avr-objcopy -O ihex -R .eeprom /tmp/build3179014252548270902.tmp/eepromtest.cpp.elf /tmp/build3179014252548270902.tmp/eepromtest.cpp.hex
Binary sketch size: 3,006 bytes (of a 32,256 byte maximum)

undefining USECONST, as follows...

Code:
#undef USECONST
#ifdef USECONST
const TYPE KEYA =  1;   
#else
#define KEYA ((TYPE) 1)   
#endif

Generates the following error output ...

Code:
avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -I/usr/share/arduino/libraries/EEPROM /tmp/build3179014252548270902.tmp/eepromtest.cpp -o /tmp/build3179014252548270902.tmp/eepromtest.cpp.o
eepromtest.cpp:42:1: error: ‘boolean’ does not name a type
eepromtest.cpp: In function ‘void setup()’:
eepromtest.cpp:57:3: error: ‘Serial’ was not declared in this scope
eepromtest.cpp:58:20: error: ‘random’ was not declared in this scope
eepromtest.cpp:59:3: error: ‘boolean’ was not declared in this scope
eepromtest.cpp:59:11: error: expected ‘;’ before ‘w’
eepromtest.cpp:60:3: error: ‘v’ was not declared in this scope
eepromtest.cpp:61:3: error: ‘w’ was not declared in this scope


In case you're wondering about including EEPROM.h, that was when I was using the code for another purpose, but I left it in anyway.

Perhaps you now feel able to comment on the operation of the IDE, Version 1.0.1, by the way.

By the way, I am well aware that const and #define do different things... I wrote the code in order to discover just how different.
Pages: [1] 2 3