C++ but really C++

 
  ParkesHub Chief Commissioner

OK.  No takers on the electronic design stuff. I'll do it myself.

Next: Are there any great C++ people at Railpage? Especially with Arduino experience.

(Do something about the ridiculous no caps title. How else to write C++?)

Sponsored advertisement

  BrentonGolding Chief Commissioner

Location: Maldon Junction
(Do something about the ridiculous no caps title. How else to write C++?)
ParkesHub
Agree, tried to post in the S312 thread the other day on my mobile and no, sorry, can't post in all caps!

BG
  dthead Site Admin

Location: Melbourne, Australia
I'm still a beginner at C++ and do dabble in Arduinos too.

Actually a  Vicual C++ subject as part of a tafe course was very useful for the arduino stuff as well.

What arre you trying to do ?



Regards,
David
  kitchgp Chief Commissioner

Is the Arduino Software (IDE) on Linux?
  ParkesHub Chief Commissioner

(Do something about the ridiculous no caps title. How else to write C++?)
Agree, tried to post in the S312 thread the other day on my mobile and no, sorry, can't post in all caps!

BG
BrentonGolding
Yeah, the original title was "c++ but really C++" then it capitalized it heading to title case anyway!!!
  ParkesHub Chief Commissioner

Is the Arduino Software (IDE) on Linux?
kitchgp
I'm just using the Arduino application that runs on my Win 10 box.
  ParkesHub Chief Commissioner

I'm still a beginner at C++ and do dabble in Arduinos too.

Actually a  Vicual C++ subject as part of a tafe course was very useful for the arduino stuff as well.

What arre you trying to do ?



Regards,
David
dthead
Hi David, I'm still writing the scoping documents. Being a PM using AgilePM and PRINCE2, the need to structure things has now become second nature to me. Unlike the early days when my VB.Net offerings were shambolic because I just went headlong into things and I had a manager who'd alter scope (meaning add to it!) on a whim. Doesn't work.

Edit: Broadly, an application that controls and reports on a solar farm. It's a broad scope.
  kitchgp Chief Commissioner

It depends on what type of device you’re building. How reliable does it have to be? Will it run continuously for long periods? Presumably it doesn’t have much memory, so things like memory leaks and segmentation faults (eg dangling pointers) could be a problem. Although it is C++ it seems like you need someone with experience using the Arduino libraries that you can consult with face-to-face. I couldn’t find any complex Arduino programs on the net, only simple ‘hello world’ ones that blink an LED, so it is difficult to tell what level of C++ is required.

Here’s some advice from a sage on the Internet (unfortunately the page got lost so am unable to provide a link) in response to a problem a user was having with an Arduino project, which started then just inexplicably stopped some time later:.

“Looks like you're talking about runtime errors (of the memory leak/segfault type) here.

There isn't any way to discover such errors (unless you comb very carefully through the code) in code that's already written. However, it is quite easy to prevent these from happening while writing the code. Just be very careful when writing loops or recursive calls; ask yourself "could this get out of hand?". If it looks like these is scope for it to "get out of hand", then write code to protect against that.

About segfaults -- just check the boundary values of array indices and you ought to be OK. If you're using pointers, then please be careful with pointer arithmetic.”


Feel free to post any queries and we can have a go at them.
  ParkesHub Chief Commissioner

It depends on what type of device you’re building. How reliable does it have to be? Will it run continuously for long periods? Presumably it doesn’t have much memory, so things like memory leaks and segmentation faults (eg dangling pointers) could be a problem. Although it is C++ it seems like you need someone with experience using the Arduino libraries that you can consult with face-to-face. I couldn’t find any complex Arduino programs on the net, only simple ‘hello world’ ones that blink an LED, so it is difficult to tell what level of C++ is required.

Here’s some advice from a sage on the Internet (unfortunately the page got lost so am unable to provide a link) in response to a problem a user was having with an Arduino project, which started then just inexplicably stopped some time later:.

“Looks like you're talking about runtime errors (of the memory leak/segfault type) here.

There isn't any way to discover such errors (unless you comb very carefully through the code) in code that's already written. However, it is quite easy to prevent these from happening while writing the code. Just be very careful when writing loops or recursive calls; ask yourself "could this get out of hand?". If it looks like these is scope for it to "get out of hand", then write code to protect against that.

About segfaults -- just check the boundary values of array indices and you ought to be OK. If you're using pointers, then please be careful with pointer arithmetic.”


Feel free to post any queries and we can have a go at them.
kitchgp
Thanks for the offer. I'll take you up on that.

Yes, it'll need to run autonomously and continuously with some heartbeat monitoring to prompt human intervention.

Some of the Arduino forums I've looked at are lacking. I bought an Arduino Bracchio to experiment with and for no other reason apart from that. Trying to find the contents of the Bracchio library is a challenge still!
  Aaron The Ghost of George Stephenson

Location: University of Adelaide SA
The reason you’ll find no hardcore projects and programming examples for arduino is because no one in industry uses arduino.

Any decent firmware coder won’t be working on a project using an aruino, they’ll be coding for the raw ATMEL device. While they might be coding in C, more likely they won’t be trusting their project’s operational qualities and reliability to a compiler. They’ll be coding directly in assembly. Some of the most hardcore projects I have seen have been coded straight into hex, as one of my old school programming lecturers once said ‘telling it exactly what to do, is the only exact way of knowing what it will do’.
  ParkesHub Chief Commissioner

The reason you’ll find no hardcore projects and programming examples for arduino is because no one in industry uses arduino.

Any decent firmware coder won’t be working on a project using an aruino, they’ll be coding for the raw ATMEL device. While they might be coding in C, more likely they won’t be trusting their project’s operational qualities and reliability to a compiler. They’ll be coding directly in assembly. Some of the most hardcore projects I have seen have been coded straight into hex, as one of my old school programming lecturers once said ‘telling it exactly what to do, is the only exact way of knowing what it will do’.
Aaron
Yes, I've coded in assembler. Often. I haven't seen C used in a while but I've been out of the loop (get it?) for a while.

Edit: But you would think the Arduino fanbois would have a tad more detail than appears to be the case. Of course, I could be looking in the wrong place.
  Aaron The Ghost of George Stephenson

Location: University of Adelaide SA
Arduino fanboys are 12-16 year olds... They’re not doing anything hardcore, they’re not working for industry and the future servicing of their projects don’t even need to be considered. So coding finesse and commenting or explanation are not their strongest points, they’re points that are not even really considered by them.

If you want something with decent reliability in timing for comms you just wouldn’t program in anything higher than assembly. Timings in C loops just cannot be gauranteed, and no one has enough room in a project timetable to go looking for a couple of misused processor cycles.
  kitchgp Chief Commissioner

This book may be of use (there is an E-book version available on other sites):
https://www.altronics.com.au/p/b2474-arduino-workshop-book/

This site
https://www.rs-online.com/designspark/build-and-program-a-braccio-robot
suggests you look in
C: Program File (x86)/Arduino/libraries/Braccio/examples
on your PC. Don’t have the software to check it but the other libraries should also have examples.
  ZH836301 Chief Commissioner

Location: BleakCity
This book comes highly recommended:

Beginning C for Arduino:Learn C Programming for the Arduino, by Ph.D. , Jack Purdum

If you have limited programming knowledge, learn something simple and high-level like Python to understand basic programming concepts.  Following that, you can try your luck learning C, then if necessary, look into features of C++ that you may need.  As most code written in C will compile in C++, depending on what you want to do programming in C may be all you need.  This approach of learning a high-level language first will also highlight the differences in C, and hopefully teach you to code properly such that you avoid things like memory leakage that will cause system crashes, of particular concern with a program running continuously on a low memory platform like the Arduino.

There's heaps of material online for learning Python, similarly for C, I'd recommend "The C Programming Language" by Kernighan and Ritchie to be the bible for C, saving trees compared with many books on programming languages which have been printed using small forests.

I've never used the Arduino, but have used Raspberry Pi's on scientific projects before - if you can't find any Arduino examples, try look at some involving them and try and rewrite them to your purpose.  Though as Aaron suggests, even scientists and engineers aren't programmers, so don't expect the greatest code when looking at examples, often you'll find things that look like they've been lazily duct-taped together from multiple, duct-taped sources until the user has arrived at something that works.  However I wouldn't agree with his suggestion that unless it's done in Assembly it's worthless - C will be fine for your purposes.

Sponsored advertisement

Display from:   

Quick Reply

We've disabled Quick Reply for this thread as it was last updated more than six months ago.