Unable to get serial to work

A shrunk down Leonardo-compatible board, thumb drive sized with native USB support. [Product info]
Post Reply
User avatar
AlchemyCS
Posts: 6
Joined: Thu Nov 29, 2012 11:06 pm
Location: Sydney, Australia

Unable to get serial to work

Post by AlchemyCS » Thu Nov 29, 2012 11:37 pm

Hi Everyone,

My first post here, so apologies if this is too much or too little info!

I've recently purchased a leostick but I'm having trouble getting the serial port(s) to work from a sketch. Probably something simple I've overlooked, but some help would be appreciated.

* The leostick has v1.1 on the board and I use the "Freetronics LeoStick V1.0" profile to program through the arduino programmer.
* I am able to upload various sketches to blink the various on-board LEDs
* I can only upload a new sketch by resetting the stick and uploading during the 7s bootloader run
* I'm using a MacBook Pro with OS X 10.7.5
* Following this post viewtopic.php?f=29&t=753 I found setting the board to Leonardo failed to upload the sketch.
* I tried replacing the

Code: Select all

while (!Serial) { ; }
with

Code: Select all

delay(8000);
* Using the below sample code I can see the led blinking ok, but no serial data.
* Serial data lights don't blink when expected
* I've tried using both

Code: Select all

Serial
and

Code: Select all

Serial1
with no luck

This is the baseline test sketch I am using. Each time I tweak the sketch I can verify it is the new one running by changing the LED that blinks:

Code: Select all

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 10;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
  Serial.begin(57600);
  delay(8000);
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  Serial.println("Hello World");
}
Any help or suggestion would be greatly appreciated!

User avatar
AlchemyCS
Posts: 6
Joined: Thu Nov 29, 2012 11:06 pm
Location: Sydney, Australia

Re: Unable to get serial to work

Post by AlchemyCS » Sun Dec 02, 2012 1:47 am

Hi Everyone,

I've had progress on this and have found some interesting interactions with the more recent mac models. Note that my topic was about the serial communications from a sketch, but this issue also includes the Keyboard and Mouse HID.

I tested the sample sketch from my initial post on a Linux box (Ubuntu) and it had no problems. I have discovered the following compatibility matrix with Macs I have current access to:

Mac Mini, 10.8.2, Mid 2011 - FAIL
iMac, 10.8.2, Mid 2007 - OK
Mac Book Pro, 10.7.4, Mid 2009 - OK
Mac Book Pro, 10.7.4, Early 2011 - FAIL
Mac Mini, 10.6.8 (server), Early 2009 - OK

So this looks like it works no problems on older macs but has issues on newer macs.

I have also found that when plugging the leostick into the 'OK' macs for the first time the keyboard detection dialog appears, but this is not the case for the 'FAIL' macs. I tried deleting the /Library/Preferences/com.apple.keyboardtype.plist and rebooting but this had no effect.

Here is where it get's interesting...

As a bit of fun I programmed into the leostick the 'tunes' sketch posted on viewtopic.php?f=29&t=162. Note this was done on a 'FAIL' computer (my computer with all my dev software). Once the leostick rebooted and started playing a tone the keyboard dialog appeared!

I reprogrammed the stick with my original test sketch but serial, keyboard and mouse still failed. I then tried plugging the same stick into the same 'FAIL' computer via a USB hub and this worked! I tried this on all the other 'FAIL' computers with the same results.

So to get the Serial, Mouse and Keyboard to be detected on the newer macs you need to play a tone or plug it in via a USB hub.

Now I haven't run any measurements, but intuitively it feels as though the newer macs are expecting a certain current draw to be notified that the device exists as a serial, keyboard or mouse device. But then again, why does the leostick loader work? Puzzled.

Anyway I am happy to have found a temporary resolution and can get on with what I was hoping to do.

Has anyone had any similar findings? Any thoughts?

cef
Freetronics Staff
Freetronics Staff
Posts: 106
Joined: Wed Nov 09, 2011 12:53 am

Re: Unable to get serial to work

Post by cef » Sun Dec 02, 2012 3:59 am

First thing I would be doing is trying to put a delay (eg: 1 second) at the start of your sketch and seeing if this helps.

It could be that things are firing off too fast and the newer Mac's don't start USB fast enough to see the data.

Might not work, but IMO that would be about the only "tangible' result of playing the tone.

User avatar
AlchemyCS
Posts: 6
Joined: Thu Nov 29, 2012 11:06 pm
Location: Sydney, Australia

Re: Unable to get serial to work

Post by AlchemyCS » Wed Dec 05, 2012 12:19 am

Hi cef,

Thanks for your input. I doubted it is was simply a delay issue as it would mean that any uploaded sketch should trigger the HID detection at some point, but this wasn't the case. HID detection only occurs after the first tone is generated.

To be thorough I did try your suggestion with delays ranging from 1s to 8s at 1 second intervals all with no luck.

However I appear to have a solution by forking and updating the supplied Freetronics core. I've created a new board type 'LeoStick V1.1' with a modified core and using this causes the HID detection to work as expected. I have a few more tests to run (once the wife has released me from active xmas decoration duty). Once I'm happy with the tests I will post the code.

effgee
Posts: 64
Joined: Tue Aug 07, 2012 2:41 am

Re: Unable to get serial to work

Post by effgee » Wed Dec 05, 2012 4:45 am

AlchemyCS wrote:(once the wife has released me from active xmas decoration duty)
What ?! There's xmas decorations that don't rely on an arduino ? I won't have a word of it.
You need to educate your wife as to what is a real xmas decoration.

User avatar
AlchemyCS
Posts: 6
Joined: Thu Nov 29, 2012 11:06 pm
Location: Sydney, Australia

Re: Unable to get serial to work

Post by AlchemyCS » Mon Dec 10, 2012 1:59 am

effgee wrote: What ?! There's xmas decorations that don't rely on an arduino ? I won't have a word of it.
You need to educate your wife as to what is a real xmas decoration.
I know, I know....I was going to show her your post but she was in the kitchen with a cleaver so I thought better of it...

User avatar
AlchemyCS
Posts: 6
Joined: Thu Nov 29, 2012 11:06 pm
Location: Sydney, Australia

Re: Unable to get serial to work

Post by AlchemyCS » Mon Dec 10, 2012 2:15 am

Ok, so after all my fluffing around trying to get the core to work as expected on modern mac computers the final refactoring is elegantly simple: don't use the Freetronics core, use the one that comes with the ardiuno IDE 1.0 (I'm using and tested with 1.0.2).

To do this you just have to make a slight modification to the boards.txt file in the arduino ide. The contents that need to be added to the file are available at gist 4222258.

This allows the LeoStick HID and serial to be detected by newer macs without issue. Interestingly it also allows the use of the tone() api without locking the board. It will show up in the IDE as Freetronics LeoStick V1.2 and Freetronics LeoStick V2.2

I've only tested this in mac and linux, so the magical windows *.inf file might need to be changed for windows.

If you have installed the ArduinoIDE 1.0.2 on a mac in the standard location (under /Applications) then you can easily amend your board.txt file with this one liner from the terminal:

Code: Select all

curl https://raw.github.com/gist/4222258/1f1e3bed05bc96df379a4a77cb63bddfa291a5ce/gistfile1.txt >> /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt 
Perhaps this would be worth posting on the LeoStick install and first time use - Mac OS X thread which has only the initial post back in February this year?

argon
Posts: 1
Joined: Sat Jan 05, 2013 2:34 am

Re: Unable to get serial to work

Post by argon » Sat Jan 05, 2013 3:26 am

Thank you AlchemyCS

After quite a bit of frustration, your fix helped me get my first LeoStick project going.

argon

clibin009
Posts: 563
Joined: Mon Oct 23, 2017 2:57 am

chenjinyan

Post by clibin009 » Fri Jan 12, 2018 3:02 am

mbt shoes
louboutin
ray ban wayfarer
canada goose outlet
ugg outlet
michael kors uk
moncler schweiz
nfl jerseys wholesale
ugg boots on sale
air max
polo shirts
coach outlet online
vibram five fingers
longchamp outlet
adidas football boots
ugg boots
coach outlet
michael kors outlet
swarovski
cheap nfl jerseys
michael kors handbags
nike outlet store
mont blanc
scarpe mbt
the north face
adidas wings
ugg outlet
michael kors outlet
uggs outlet
scarpe hogan
ugg boots
ugg boots
adidas jeremy scott
cheap mlb jerseys
nike sb
nhl jerseys
cheap ray bans
michael kors outlet clearance
cheap nhl jerseys
michael kors
tory burch
pandora rings
canada goose jackets
michael kors handbags
moncler
ugg clearance
giuseppe zanotti shoes
coach outlet online
cheap nfl jerseys
cheap rolex watches
kate spade
michael kors outlet
coach handbags
ugg boots
tory burch
jordans
louboutin
nike air force
jordans
michael kors handbags
nike air
balance shoes
salvatore ferragamo
air max
nike outlet
oakley sunglasses
north face
coach factory outlet online
fitflops
birkenstock
nike football boots
timberland outlet
ralph lauren
ugg australia
michael kors
ugg
nike tn
birkenstock outlet
coach outlet online
pandora charms
nike blazer
ralph lauren outlet
ray ban sunglasses
pandora jewelry
ralph lauren uk
coach factory outlet online
coach outlet online
pandora jewelry
fitflops outlet
ray ban sunglasses
the north face
jordan retro
coach outlet online
timberland boots
hermes
polo ralph lauren
moncler
ugg outlet
coach outlet online
nike free run
nike uk
stan smith shoes
ugg boots sale
pandora jewelry canada
birkenstock sandals
north face uk
burberry scarf
canada goose jackets
longchamp
pandora jewelry
louboutin
coach factory online
ralph lauren
canada goose
air max
polo ralph lauren outlet
michael kors outlet
true religion jeans
oakley sunglasses wholesale
ralph lauren
michael kors outlet online
ugg outlet
burberry outlet
uggs
adidas yeezy
tory burch outlet
ray ban
air jordan 14
supreme outlet
kate spade handbags
ugg boots
nike outlet
north face jackets
ray ban
ray ban
ralph lauren uk
michael kors outlet
longchamp
louboutin
supreme uk
mont blanc pens
true religion jeans
prada
beats by dre
cheap jordans
nike factory outlet
jordan
ugg canada
ugg boots
nike huarache shoes
moncler outlet
coach outlet online
north face outlet
burberry scarf
tommy hilfiger
jordans
ray ban
ugg outlet store
coach factory outlet
nba jerseys
north face
oakley sunglasses
michael kors outlet
nike store uk
oakley sunglasses
louboutin
true religion jeans
flops
cheap mlb jerseys
the north face
under armour outlet
canada goose outlet
michael kors taschen
canada goose outlet
nike air max
pandora charms
tory burch outlet
true religion jeans
coach outlet
christian louboutin
ray ban
ray ban
ugg
jordan shoes
nike air max
ugg outlet
ferragamo outlet
ugg pas cher
moncler pas cher
polo ralph lauren
air jordan
michaelkors outlet online
moncler
coach
basketball shoes
uggs
juicy couture outlet
canada goose jackets
canada goose jackets
pandora uk
mac cosmetics
kate spade
moncler
air jordan
jordans
snapbacks wholesale
hermes outlet
ray ban sunglasses
ralph lauren
canada goose sale
michael kors outlet
cheap ugg boots
cheap ugg boots
polo ralph
manolo blahnik shoes
polo ralph
canada goose jackets
coach handbags
adidas outlet store
moncler outlet
flops
north face outlet
ugg italia
ralph lauren uk
mlb jerseys
coach outlet
ugg boots
north face jackets clearance
ugg outlet
burberry outlet canada
uggs
flip flops
doudoune canada goose
ugg boots
uggs outlet
ugg
coach outlet online
polo ralph lauren
oakley sunglasses
ray ban sunglasses
adidas stan smith shoes
swarovski crystal
uggs outlet
air jordan
flip flops
north face jackets
michael kors outlet
jordan shoes
uggs outlet
nike air max
polo ralph
timberland pro
jordan
north face
uggs outlet
replica watches
ugg boots
longchamp outlet
jordan shoes
canada goose
hermes birkin bags
north face uk
polo ralph lauren
adidas superstar
canada goose
red bottom shoes
jordan shoes
pandora
mcm bags
nike factory outlet
adidas uk
ray ban sunglasses wholesale
ugg
canada goose outlet
adidas shoes
prada handbags
coach factory outlet
supra shoes
burberry outlet online
louboutin
moncler
baseball jerseys
michael kors outlet
kate spade
north face
air max
supreme
uggs outlet
oakley sunglasses
coach factory outlet
adidas outlet
cheap oakley sunglasses
oakley canada
michael kors handbags
ugg boots
mulberry handbags
north face
canada goose jackets
ugg boots
true religion
coach outlet
canada goose
ugg boots
michael kors outlet
north face outlet
coach factory outlet
louboutin
uggs outlet
christian louboutin
timberland boots
ugg
oakley sunglasses
ferragamo shoes
ugg boots
louboutin
prada
kate spade
moncler outlet
hermes uk
canada goose canada
the north face
nike outlet
timberland boots
north face
ugg canada
oakley vault
doudoune canada goose
ugg outlet
coach outlet
oakley sunglasses
cheap nfl jerseys
nfl jerseys wholesale
canada goose sale
moncler jackets
prada bags
moncler
jordan shoes
true religion jeans
moncler
soccer jerseys
canada goose jackets
blackhawks jersey
ray ban sunglasses
longchamp handbags
moncler
coach
moncler jackets
nike air huarache
ralph lauren
pandora jewelry canada
longchamp
mont blanc pens
superdry clothing
converse shoes
louboutin
jordan pas cher
ugg boots
kate spade outlet
canada goose
ugg boots
ralph lauren
cheap nfl jerseys
adidas shoes
20181.12chenjinyan

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests