f-log

just another web log

16 Sep 2013:
Teensy comms what could be easier
Continued from Teensy dev on gentoo linux really is this easy

Next step comms, else I am running blind and as my electronics knowledge/skill has "issues" that would be bad!

Documentation shows that getting data from the Teensy 3.0 is really easy. Just set up the port and start writing to it! open the serial monitor from inside Arduino and listen.
// Teensy 3.0 has the LED on pin 13 **THAT'S PIN 13 !! NOT 11 or 12 PIN 13! ARE YOU LISTENING?!
const int ledPin = 13;

void setup() {
// initialise the digital pin as an output.
pinMode(ledPin, OUTPUT);
Serial.begin(38400);
Serial.println("It begins");
}

void loop() {
Serial.println("and ...");
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000);                 // wait for a second
digitalWrite(ledPin, LOW);    // set the LED off
delay(500);                 // wait for a second
}

But nothing is ever easy and that did not work. Seems the serial monitor is not available ...

Google,Google,Google ...

Add user to tty and uucp groups
gpasswd -a YOUR_USERNAME tty
gpasswd -a YOUR_USERNAME uucp


Woo hoo! we have serial monitor but ... nothing is output.

Google,Google,Google ...

Add the following to the kernel. About time I rebuilt my kernel ...
(I have a funny story about rebuilding this particular kernel but it can wait for now)

Device Drivers --->
    [*] USB support --->
        <*> USB Serial Converter support --->
            <*> USB FTDI Single Port Serial Driver

Device Drivers --->
    [*] USB support --->
        <*> USB Modem (CDC ACM) support


Now the default in Arduino was /dev/ttyS0 which seemed very reasonable. WRONG!
The correct serial port was /dev/ttyACM0 which I could select from the Tools/Serial Port: menu.

Opened the Serial Monitor and uploaded the code to the Teensy 3.0 and ... The serial monitor closed itself, but upon re-opening it manually there were my messages every time the flash cycle repeated!

I just need to find the "Keep Serial Monitor Open" or "Open Serial Monitor when deploying code" option. None exists and appears to be a major bug bear to many people. Although you can fix this in the open source Arduino its not going to fixed in the release version due to cross platform compatibility.

OK OK. So, how else can we get the data from the Arduino?

screen /dev/ttyACM0 38400
worked (CTRL+a :quit) but lost connection if I uploaded new code to the Teensy 3.0

Screen was too slow to use in a loop
for i in {1..10}; do echo $i;screen /dev/ttyACM0 38400; done
Some kind of timeout meaning it was easier to manually kill it and start a new instance.

so I wrote my own (bad) python(v3) script
import serial

def listen():
    ser = serial.Serial('/dev/ttyACM0', 38400)
    while True:
        print(ser.readline())

while True:
    try:
        listen()
    except Exception as e:
        print("error captured: " + str(e))

(needs pySerial library installed)

But even that did not capture the first message.

error captured: could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
error captured: could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
error captured: could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
error captured: could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
error captured: could not open port /dev/ttyACM0: [Errno 13] Permission denied: '/dev/ttyACM0'
error captured: could not open port /dev/ttyACM0: [Errno 13] Permission denied: '/dev/ttyACM0'
error captured: could not open port /dev/ttyACM0: [Errno 13] Permission denied: '/dev/ttyACM0'
b'and ...\r\n'
b'and ...\r\n'
b'and ...\r\n'
b'and ...\r\n'

(error messages truncated for brevity)

So there is no way to make sure you get the first messages. Not a problem, just another lesson learned speaking of which I REALLY should have ordered the Teensy 3.0 with Pins
16 Sep 2013:
Teensy dev on gentoo linux really is this easy
Continued from Teensy, it begins in windows

Now to get the Teensy working in linux.

I downloaded the Arduino software for linux and unpacked it then ran Teensyduino and selected the Arduino folder. The gentoo emerge arduino version did not work (and is noted on the Teensy website, my bad.

Then (as root) copied the udev rules file to /etc/udev/rules.d/
Moment of truth, plugged Teensy in ...
dmesg
usb 2-6: udev 8, busnum 2, minor = 135
usb 2-6: New USB device found, idVendor=16c0, idProduct=0483
usb 2-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-6: Product: USB Serial
usb 2-6: Manufacturer: Teensyduino
usb 2-6: SerialNumber: 10138
usb 2-6: usb_probe_device
usb 2-6: configuration #1 chosen from 1 choice
usb 2-6: adding 2-6:1.0 (config #1, interface 0)
usb 2-6: adding 2-6:1.1 (config #1, interface 1)
and the blink code from windows was running without having to press the button.

Ran Arduino, selected the board as Teensy 3.0 loaded the Blink example under Tutorial 1 and ...

Opening Teensy Loader...
Unable find Teensy Loader. Is the Teensy Loader application running?

hmmmm
Seems I need to manually start the teensy app../teensy
./teensy: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory
Oh great!
emerge libpng:1.2
And its running !!
And I managed to upload the default Blink sketch code targeting an older board *AGAIN* so sat looking at a non blinking Teensy. Followed my own advice and *READ* the comments, updated the pin number for the LED to 13 and away we go!
This is great, I was really worried that linux based development just would not be possible especially with gentoo after the notes at Teensy.
Stage one of my plan to overthrow all the worlds governments is complete only 64,599 steps to GO!

FYI, future uses of Arduino automatically started the Teensy Loader auto-magically.
16 Sep 2013:
Teensy, it begins in windows
Earlier in the year I purchased a Teensy 3.0 a tiny (really small) micro-controller board. The truly amazing thing about the Teensy is not the size but the price. Just $19, but having it shipped to the UK was another $10 but that's still less than £20!

Talking of size, this thing is just 1.4 by 0.7 Inches which is 35.56mm x 17.78mm

size comparison of the Teensy 3.0 and an SD card, wifi dongle, 2 pence piece and 3 pencils. Top view
size comparison of the Teensy 3.0 and an SD card, wifi dongle, 2 pence piece and 3 pencils. Side view

So that's not even as wide as three standard HB pencils and conversely not as long as the width of six standard HB pencils.

There is some somewhat confusing documentation, but to get it working out of the box (it came in an anti-static bag) just plugin it in to a USB micro B cable(not supplied, these come with every non apple mobile phone) and connect a power source (i.e. a computers USB socket). The board will the blink and that blinking is the code that is pre-loaded onto the system.

I wanted to get something slightly more interesting on the board and to do it from Linux but the system was busy and I had a Windows laptop lying idle.
To get your own code onto the Teensy you need the open source Arduino software, which you just extract from a zip and then install the Teensyduino. This process is simple, just point at the folder where the Arduino files were extracted and it will do its thing. I had to run as Administrator to get it to install a virtual COM port.

Then run Arduino select the board as Teensy 3.0 (tools menu) and load one of the examples (File/Examples/Teensy). The Tutorial section of the Examples has (unsurprisingly) a Blink file, but running this produced no blinking! A quick glance at the comments at the top the file reveal that the hardware address for the LED is different for each version of the Teensy. Updating it from 11 to 13 and running again got me my blink back.

The Blink code is; a simple setup; loop forever; with delays turning on and off the LED. I changed the first delay from 1000 to 3000 and now the board blinks on for three seconds and the waits just one second while the LED is off and then turning back on for three seconds ad infinitium.

But what I really want is to continue Teensy development in linux ...
07 Sep 2013:
bing has secret powers to reverse ip domain hosting
Found this blog post about Attributing Potentially Malicious URLs and picked up a tip that I thought was impossible.
Using bing.com with the query ip:82.165.83.145 where 82.165.83.145 is the server hosting www.jumpstation.co.uk. The search results will be ALL the domains hosted on that IP address.
Wonder how they do it ?!
loading results, please wait loading animateloading animateloading animate
[More tags]
rss feed

email

root

flog archives


Disclaimer:
This page is by me for me, if you are not me then please be aware of the following
I am not responsible for anything that works or does not work including files and pages made available at www.jumpstation.co.uk I am also not responsible for any information(or what you or others do with it) available at www.jumpstation.co.uk
In fact I'm not responsible for anything ever, so there!

[Pay4Foss banner long]