Pages: [1]   Go Down
Author Topic: #ifdef / #switchdef / array for upload to multiple targets (same HW)  (Read 178 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
just sun
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hello community,

i will have to program ~20 ArduinoEthernet boards - all with the identical sketch -
but every board has a uniq mac and a ipaddress -
so i searching for an idea to 'define' the 'Hardware/Bord-Specific' parameters for all boards -
and than choose in an easy way which one to use for the current upload target (connected board)..

i have two different ideas till now -
1 - use a array to store all possible configs
Code:
tDeviceParameters dpDeviceList[] = {
{ // -- not used.
 0, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x00 }, // mac
IPAddress(192, 168, 222, 100), // ip
},
{ // development board
 1, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x4E }, // mac
IPAddress(192, 168, 222, 101), // ip
},
{ // test board
 2, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x43 }, // mac
IPAddress(192, 168, 222, 102), // ip
},
{ // second test board
 3, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x45 }, // mac
IPAddress(192, 168, 222, 103), // ip
},
};

tDeviceParameters dpThisDeviceX = dpDeviceList[1]; // number is identical with ID == identical with IPAddress ending.
problem: all infos are using space... but only one is used...

2 - use a list of #ifdef s
Code:
#define DEVICE_1

#ifdef DEVICE_1
tDeviceParameters dpThisDevice = {
// development board
 1, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x4E }, // mac
IPAddress(192, 168, 222, 101), // ip
};
#endif

#ifdef DEVICE_2
tDeviceParameters dpThisDevice = {
// second test board
 2, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x43 }, // mac
IPAddress(192, 168, 222, 102), // ip
};
#endif

#ifdef DEVICE_3
tDeviceParameters dpThisDevice = {
// second test board
 3, // cbID
{ 0x90, 0xA2, 0xDA, 0x0E, 0x0E, 0x45 }, // mac
IPAddress(192, 168, 222, 103), // ip
};
#endif
//...
this is not so nice from the formating  ?!  smiley-cool

have someone out there another idea / concept to do something like this?
i have added my test sketch - its the basic UDPSendReceiveString Example with small modifications.
or is the compiler so clever to know that only one of the entrys in an array is used in the software?

sunny greetings
stefan

* DeviceInfo.h (0.4 KB - downloaded 3 times.)
* Example_UDPSendReceiveString.ino (4.15 KB - downloaded 2 times.)
« Last Edit: November 14, 2013, 07:19:36 am by s-light » Logged

UK
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3969
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Option 3: give them all the same sketch, and store the MAC / IP in EEPROM.
Logged

Why not visit my eBay shop? http://stores.ebay.co.uk/Majenko-Technologies
Replacement for the Arduino IDE: UECIDE - Proper serial terminal, graphing facilities, plugins, overhauled internals.
Java isn't bad in itself, but it has enabled morons to write programs.

0
Offline Offline
Shannon Member
****
Karma: 161
Posts: 10438
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I'd suggest writing a config sketch that just takes the MAC / IP from serial and stores
it in the EEPROM, reads it back and prints to serial for confirmation, upload that
and run it for each board to configure.

Then upload the sketch that does what you want using EEPROM.   You can always
make the EEPROM uploading an option of the main sketch if you need to, of course.

You may want to use DHCP and avoid uploading the IP.

Also if you are using an ethernet or WiFi card it should have a MAC ROM already...
Logged

[ I won't respond to messages, use the forum please ]

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
just sun
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for the suggestion with the EEPROM.
i haven't worked with this up to now ;-)
so its a good idea to look into it.

the fixed ip is by design. in the system where this boards will be used are no dhcp. all server and clients have fixed ips.
Also if you are using an ethernet or WiFi card it should have a MAC ROM already...
iam using the ArduinoEthernet boards - so its the same like an UNO + Ethernet-Shield
so the W5100 has a programmed mac?
than i think there would be a option to read that out with the Ethernet library..

sunny greetings
stefan
Logged

Pages: [1]   Go Up
Jump to: