Online C++ compilers

There are multiple C++ compilers available on the net which can be used online. The advantage is that you can check your prototypes and share them easily.

 CompilerStandardSyntax highlightingShow program stdoutInteractive inputView Assembler output
http://cpp.sh/gcc 4.9.2, Boost 1.55 availableC++98
C++11
C++14
yesyespossibleno
http://coliru.stacked-crooked.com/gcc 4.6
gcc 4.7
gcc 4.8
gcc 4.9
gcc 5.1
clang-3.6
C++98
C++11
C++14
C++17
yesyesnono
https://gcc.godbolt.org/ARM gcc 4.5.3
ARM gcc 4.6.3
ARM gcc 4.8.2
ARM64 gcc 4.8
AVR gcc 4.5.3
PowerPC gcc 4.8
x86 clang 3.0
x86 clang 3.2
x86 clang 3.3
x86 clang 3.4.1
x86 clang 3.5.0
x86 clang 3.5.1
x86 clang 3.6 (rc2)
x86 clang 3.7 (experimental)
x86 gcc 4.4.7
x86 gcc 4.5.3
x86 gcc 4.6.4
x86 gcc 4.7.3
x86 gcc 4.8.1
x86 gcc 4.8.2
x86 gcc 4.9.0
x86 gcc 4.9.0 (w/concepts)
x86 gcc 4.9.0 (w/concepts)
x86 gcc 4.9.2
x86 gcc 5.1.0
x86 icc 13.0.1
yesnonoyes
http://webcompiler.cloudapp.net/Microsoft Visual Studio 2015
19.00.23008.0(x86)
http://ideone.com/gcc 4.9.2
gcc 4.9.2 (C++14)
http://melpon.org/wandbox

Remarks

Example command lines for the Coliru online compiler

g++-4.6 -std=c++98  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.7 -std=c++98  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.7 -std=c++11  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.8 -std=c++98  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.8 -std=c++11  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.9 -std=c++98  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.9 -std=c++11  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.9 -std=c++14  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-5.1 -std=c++98  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-5.1 -std=c++11  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-5.1 -std=c++14  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-5.1 -std=c++1z  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
clang++ -std=c++98  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
clang++ -std=c++11 -stdlib=libc++  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  -lsupc++  && ./a.out
clang++ -std=c++14 -stdlib=libc++  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  -lsupc++  && ./a.out
clang++ -std=c++1z -stdlib=libc++  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  -lsupc++  && ./a.out

Other languages

http://ideone.com/ supports a lot of other languages, too.

31C3

Mit dem ICE nach Hamburg. Dafür gibt es das Spezial-CCC-Ticket der Bahn für 99 EUR (zuggebunden, 2.Klasse,Hin und Zurück). Während des Kongresses war es kalt und es gab sogar ein wenig Schnee.

image

Im Kongresszentrum selber war die Atmosphäre sehr gut. Wie immer und wie erwartet war die Organisation ein klein wenig chaotisch. Z.B. wollte die Food Hacking Base erst einmal gefunden werden oder man musste hellseherische Fähigkeiten entwickeln um zu wissen wann welcher Workshop ist nachdem der Zugang zum Wiki am 3. Tag gehackt wurde.

Die drei Tage, die ich auf dem Kongress bleiben konnte, haben sehr viel Spaß gemacht. Hier ein paar meiner persönlichen Highlights:

Vorträge:

Daneben gab es noch:

Diese Vorträge habe ich selber nicht gehört, es scheint sich aber zu lohnen den Stream dazu anzuschauen:

So, und für nächstes Jahr merk' ich mir:

  • Software daheim updaten
  • Genügend Speicherplatz mitnehmen
  • Frühzeitig (am 1. Tag?) interessante Projekte finden und darauf rumhacken. Dann kann man am 2./3. Tag jemandem Fragen dazu stellen.
  • Fahrplan / Lightning Talks / Workshops -> (mehrmals) mirroren, falls Server ausfällt bzw. gehackt wird.
  • Kopfhörer mitnehmen

Build a simple Webserver with Pollin AVR-NET-IO using the Arduino software stack

0. Programmer

I'm using an Arduino as ISP to flash the webserver to the AVR-NET-IO. See my previous post Dump ATMEGA32 on AVR-NET board using avrdude for how to convert the Arduino to a programmer and how to wire the connections between the Arduino (programmer) and the AVR-NET-IO. Do not connect AVR-NET-IO's own power source when it is connected to the Arduino (programmer).

1. ATmega32

The AVR-NET-IO uses the ATmega32 microcontroller about which the Arduino IDE does not know anything. Thankfully, Eric Conner has written a definition file for the ATmega32 needed by the Arduino IDE.

1.1. Download definitions from https://github.com/eaconner/ATmega32-Arduino and follow the instructions to install the mega32 variant files.

1.2. Patch the pins_arduino.h file to contain the following additional lines:

static const uint8_t SS   = 4; // D4
static const uint8_t MOSI = 5; // D5
static const uint8_t MISO = 6; // D6
static const uint8_t SCK  = 7; // D7

I have the file in the following directory:

%USERPROFILE%\Documents\Arduino\hardware\mega32\variants\mega32\pins_arduino.h

2. ENC28J60 network chip

The Pollin board also contains an ENC28J60 network chip. This cannot be addressed by the Arduino Ethernet library directly but there is a wonderful replacement library available from Norbert Truchsess at

https://github.com/ntruchsess/arduino_uip

Install the library as described in the installation instructions on the above link.

I have the library files in the following directory:

%USERPROFILE%\Documents\Arduino\libraries\UIPEthernet

e.g. the file %USERPROFILE%\Documents\Arduino\libraries\UIPEthernet\Dhcp.cpp

3. Webserver

3.1. Start Arduino IDE, open from the menu Examples / Ethernet / WebServer .

3.2. Change the include directive

#include <Ethernet.h>

to

#include <UIPEthernet.h>

4. Compile and Upload

4.1. In Arduino IDE menu select: Tools / Programmer / Arduino as ISP

4.2.  Select Tools / Board / ATmega32-External 16MHz

4.3. File / Upload using Programmer (this sometimes aborts with error message "Not int sync". Simply give it a second try.

4.4. Make sure to disconnect the Arduino (programmer) from the AVR-NET-IO before you connect AVR-NET-IO's own power source.

Read fuses of ATMEGA32 on AVR-NET-IO

Same configuration as described in the previous post Dump ATMEGA32 on AVR-NET board using avrdude. Then

bin\avrdude.exe -C etc\avrdude.conf -c avrisp -p ATMEGA32 -P com4 -b 19200 -v

The output for was


avrdude.exe: Version 5.11, compiled on Sep  2 2011 at 19:38:36
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2009 Joerg Wunsch

             System wide configuration file is "etc\avrdude.conf"

             Using Port                    : com4
             Using Programmer              : avrisp
             Overriding Baud Rate          : 19200
             AVR Part                      : ATMEGA32
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PA0
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :

                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom         4    10    64    0 no       1024    4      0  9000  9000 0xff 0xff
               flash         33     6    64    0 yes     32768  128    256  4500  4500 0xff 0xff
               lfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
               hfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
               lock           0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
               calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00

             Programmer Type : STK500
             Description     : Atmel AVR ISP
             Hardware Version: 2
             Firmware Version: 1.18
             Topcard         : Unknown
             Vtarget         : 0.0 V
             Varef           : 0.0 V
             Oscillator      : Off
             SCK period      : 0.1 us

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude.exe: Device signature = 0x1e9502
avrdude.exe: safemode: lfuse reads as FF
avrdude.exe: safemode: hfuse reads as CA
avrdude.exe: current erase-rewrite cycle count is -1062731548 (if being tracked)

avrdude.exe: safemode: lfuse reads as FF
avrdude.exe: safemode: hfuse reads as CA
avrdude.exe: safemode: Fuses OK

avrdude.exe done.  Thank you.

Use the Engbedded Atmel AVR® Fuse Calculator to interpret the values

lfuse reads as FF
hfuse reads as CA

from the output above.

Clock source

CKSEL3 [ ]
CKSEL2 [ ]
CKSEL1 [ ]
CKSEL0 [ ]

means External crystal

Boot

BOOTSZ1 [X]
BOOTSZ0 [ ]

means Boot size 1024 words

BOOTRST [X]

means program counter points to bootloader (instead of 0xC00) after reset

My visit at the Easterhegg 2014 in Stuttgart, Germany

Interesting things I've learned at the Easterhegg in Stuggart. I've been there Saturday and Sunday only.

Day 2

  • dawanda used cross device responsive tables
  • Better presentations with a workshop by Dirk Haun. We heard about the Rule of Thirds, no bullet points, images from http://freeimages.com, http://www.flickr.com/creativecommons/, ...
  • ImageMagick can create 3D software boxes from images.
  • Adafruit sells LED strips that can be used by Arduino easily
  • palava.tv uses WebRTC and an open source central signaling server to enable peer to peer (P2P) video and audio chats and conferences. Soon the server might be available in an SD card image for the Raspberry Pi.

Day 3

  • AYAB - all yarns are beautiful: Project to connect old Brother KH-910 and KH-930 knitting machines to computers to knit images of 200px width (and arbitrary height). Project located in Munich (MuCCC). Uses Arduino, Python, and (future work) PyQt. https://wiki.muc.ccc.de/ayab, http://www.ayab-knitting.com/
  • A few ideas about CNC machining, e.g. Shapeoko, importance of good common ground, ...
  • Spice up your presentations with reveal.js (e.g. http://palavatv.github.io/talk-webmontag/)and use Unicode characters, e.g. for :poop:. See fileformat.info for a detailed list. I have to learn about Emojis/Gemojis...
  • The version of a framework used in Java can be obtained by analysing its stack trace, especially the classname together with the line numbers. Maybe you should take care that your web server never prints that trace in case of errors.
  • Do not accept jobs that force you to make overtime hours that will be lost at the end of the month.
  • Baozi might be interesting to cook myself. Didn't have the time to go to the workshop.
  • A few introducery things about CAN and CANopen.
  • DMX, the protocol used for event technology (Veranstaltungstechnik) is very simple and can be used from Arduino, too. Maybe script a few cool effects using DMX isn't very hard. Just send a reset, a NULL, a node id and a value between 0 and 511 and your light starts to shine proportional - http://eh14.easterhegg.eu/pages/fahrplan/events/5772.html
  • A few very interesting details about how to sell your own electronics.
  • Weller PU 81 soldering stations are very expensive
  • There are quadrocopters that can carry 4kg

Half-height SD cards

Most SD cards seem to have only half of the plastic housing filled with electronics. If you need a half-height SD card, e.g. such that it does not stick out of a notebook too much, you can simply cut the SD card in half. Before doing this, take a very bright LED (e.g. from your mobile) to shine through the plastic and see whether there is really no electronics in this half of the SD card. Then open the housing carefully. If it's really empty, you can cut it off.

2013-09-16 18.02.59

2013-09-16 18.07.43

2013-09-16 18.10.43

2013-09-16 21.13.52

HP8500A Paper Jam Mystery

This weekend I tried to repair a Hewlett Packard 8500A printer, 2 month after the 2 years guarantee was over. The display showed "Paper jam" error messages each time the printer was booted, which was a false error.

As it turned out, the problem was a broken cog, as can be found very often in your prefered search engine.

There are other images and videos online, e.g.

  • https://www.youtube.com/watch?v=PMFW1RRlDHE

or

  • http://h30434.www3.hp.com/t5/Printer-All-in-One-Install-Setup/Officejet-Pro-8500-paper-jam-error/td-p/289467

These are the images of my broken HP8500A after removal of the black plastic housing around the broken white cog:

Overview 1:

2014-04-13 20.57.53

Come closer to the broken cog:

2014-04-13 20.58.12

 

 

The removed plastic housing:

2014-04-13 20.59.09

And here we have the broken cog:

2014-04-13 21.00.30

 

I tried to glue the cog, but with no success. It seems the printer cannot be fixed.

Dump ATMEGA32 on AVR-NET board using avrdude

Using the ArduinoISP program on the Arduino (actually I used the Diavolino) one can dump the flash memory of the ATMEGA32 on the AVR-NET-IO from Pollin like this:

  1. Program ArduinoISP to your Arduino
  2. Wire up like this:pollin_avrnetio
  3. Open CMD. Go to your avrdude directory within the Arduino IDE and execute avrdude. Maybe you have to adapt the -P parameter to the serial port you are using to connect to Arduino.
cd "C:\Program Files (x86)\Arduino\hardware\tools\avr"
bin\avrdude -C etc\avrdude.conf  -c avrisp  -p ATMEGA32 -P com4 -b 19200 -U flash:r:C:\TEMP\flash_v103_pollin.bin:r

Your output look like this:

C:\Program Files (x86)\Arduino\hardware\tools\avr>bin\avrdude -C etc\avrdude.conf  -c avrisp  -p ATMEGA32 -P com4 -b 19200 -U flash:r:C:\docs\AVR-NET\flash_v103_pollin.bin:r

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.10s

avrdude: Device signature = 0x1e9502
avrdude: current erase-rewrite cycle count is -1062731548 (if being tracked)
avrdude: reading flash memory:

Reading | ################################################## | 100% 27.89s

avrdude: writing output file "C:\docs\AVR-NET\flash_v103_pollin.bin"

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

The md5sum of the dumped flash memory image is

$ md5sum flash_v103_pollin.bin
4d040732d01c6aa88ec2dad4ddf56dea *flash_v103_pollin.bin