Giter Club home page Giter Club logo

avrgirl-arduino's Introduction

Build Status Coverage Status

avrgirl-arduino

A NodeJS library for flashing compiled sketch files to Arduino microcontroller boards.

πŸ†•Alpha release of web serial support for some Arduino boards πŸ†•

Want to contribute?

Own a supported Arduino and want to be a test pilot for this project with two minutes of your time?

  1. Run npm install -g avrgirl-arduino@latest in your terminal.
  2. Type avrgirl-arduino test-pilot, hit enter / return key and follow the prompts.
  3. Thank you, friend ❀️

logo

What is this?

avrgirl-arduino is a NodeJS library written to present a convenient way to upload precompiled sketches to an Arduino. avrgirl-arduino supports a selection of Arduino boards.

The current supported list:

  • Arduino Uno
  • Arduino Mega
  • Arduino ADK
  • Arduino Leonardo
  • Arduino Micro
  • Arduino Nano
  • Arduino Duemilanove (168)
  • Arduino Pro Mini
  • Arduino Lilypad USB
  • Arduino Yun
  • Arduino Esplora
  • Femtoduino IMUduino
  • RedBearLab Blend Micro
  • Tinyduino
  • Sparkfun Pro Micro
  • Qtechknow Qduino
  • Pinoccio Scout
  • Adafruit Feather 32u4 Basic Proto
  • Arduboy
  • Adafruit Circuit Playground
  • BQ Zum
  • BQ ZUM Core 2
  • BQ ZUM Core 2

This library is designed to ultimately be rolled into the avrgirl project (in development), however it still works perfectly well as a stand-alone package to be used outside of avrgirl if you wish.

How to install

  1. Install NodeJS from nodejs.org
  2. Run npm install avrgirl-arduino in your shell of choice

For Windows users

Before using your Arduino with avrgirl-arduino on Windows XP, 7, and 8, you may need to install the Arduino drivers included with the Arduino IDE. You can follow steps 1-4 on this guide to install the Arduino IDE and activate the relevant drivers. After step 4 of the guide (drivers) you will be ready to use your Arduino with avrgirl!

How do I use it?

Your first task is to source a pre-compiled .hex file of the sketch you're interested in uploading to your Arduino. It needs to be compiled for your specific Arduino. You'll find some example hex files for each board within the junk/hex folder of this repo, however if you'd like to use your own, see this guide if you're unsure of how to go about this.

Already have a .hex file in a Buffer object ready to go? No problem! Pass this Buffer object in instead of the file path string, and avrgirl-arduino will take care of the rest. Hooray!

Don't forget to plug your supported Arduino of choice into an available USB port on your computer!

Wanna use this in the CLI? See this section.

The following example code should get you up and running with an Arduino Uno:

var Avrgirl = require('avrgirl-arduino');

var avrgirl = new Avrgirl({
  board: 'uno'
});

avrgirl.flash('Blink.cpp.hex', function (error) {
  if (error) {
    console.error(error);
  } else {
    console.info('done.');
  }
});

When creating new Avrgirl(), only the board property is required. The board names to use are detailed in the table below:

Programmer Board Option String
Arduino Uno uno
Arduino Mega mega
Arduino ADK adk
Arduino Leonardo leonardo
Arduino Micro micro
Arduino Nano nano
Arduino Nano (with new bootloader) nano (new bootloader)
Arduino Lilypad USB lilypad-usb
Arduino Duemilanove duemilanove168
Arduino Yun yun
Arduino Esplora esplora
RedBearLab Blend Micro blend-micro
Tiny Circuits Tinyduino tinyduino
SparkFun Pro Micro sf-pro-micro
Qtechknow Qduino qduino
Pinoccio Scout pinoccio
Femtoduino IMUduino imuduino
Adafruit Feather 32u4 Basic Proto feather
Arduboy arduboy
Adafruit Circuit Playground circuit-playground-classic
BQ ZUM bqZum
BQ ZUM Core 2 zumcore2
BQ ZUM Junior zumjunior

You can optionally specify a port to connect to the Arduino, but if you omit this property avrgirl-arduino will do a pretty good job of finding it for you. The exception to this is if you're using the Arduino Pro Mini - please specify your port in this case as avrgirl-arduino cannot auto detect it for you.

Specifying the port would look something like this:

var avrgirl = new Avrgirl({
  board: 'uno',
  port: '/dev/cu.usbmodem1412'
});

You can list available USB ports programmatically using the the list method:

Avrgirl.list(function(err, ports) {
  console.log(ports);
  /*
  [ { comName: '/dev/cu.usbmodem1421',
  	   manufacturer: 'Arduino (www.arduino.cc)',
      serialNumber: '55432333038351F03170',
      pnpId: '',
      locationId: '0x14200000',
      vendorId: '0x2341',
      productId: '0x0043',
      _standardPid: '0x0043' } ]
  */
});

Alternatively, you can use the CLI to list active ports:

$ avrgirl-arduino list
[ { comName: '/dev/cu.usbmodem1421',
  	 manufacturer: 'Arduino (www.arduino.cc)',
    serialNumber: '55432333038351F03170',
    pnpId: '',
    locationId: '0x14200000',
    vendorId: '0x2341',
    productId: '0x0043',
    _standardPid: '0x0043' } ]

Like logs? Turn on debug mode to see simple flashing progress logs in the console:

var avrgirl = new Avrgirl({
  board: 'uno',
  // turn on debug mode!
  debug: true
});

A sample:

found uno on port /dev/cu.usbmodem14141
connected
flashing, please wait...
flash complete.

Prefer your own custom debug behaviour? No Problem!

You can pass in your own debug function instead of a boolean, and avrgirl-arduino will run that instead.

Example:

var myCustomDebug = function(debugLogString) {
  // do your own debug stuff in here
}

var avrgirl = new Avrgirl({
  board: 'uno',
  // turn on debug with your own function
  debug: myCustomDebug
});

Have a device that requires a manual reset?

You can pass in a manualReset property as a boolean, in either your custom board object or in the general Avrgirl options. This will skip the reset flow when flashing the board. Please note that this is only available for use with boards that speak the AVR109 protocol (most ATMega32U4 powered boards).

Example without custom board:

var avrgirl = new Avrgirl({
  board: 'leonardo',
  // you can put it here:
  manualReset: true
});

Example with custom board:

var board = {
  name: 'micro',
  baud: 57600,
  signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]),
  productId: ['0x0037', '0x8037', '0x0036'],
  protocol: 'avr109',
  // or you can put it here:
  manualReset: true
};


var avrgirl = new Avrgirl({
  board: board
});

Want to Disable Code Verification?

You can pass in a disableVerify property as a boolean, in either your custom board object or in the general Avrgirl options. This will skip the Verification after flashing the board. Please note that this is only available for use with boards that speak the AVR109 protocol (most ATMega32U4 powered boards).

Example without custom board:

var avrgirl = new Avrgirl({
  board: 'leonardo',
  // you can put it here:
  disableVerify: true
});

Example with custom board:

var board = {
  name: 'micro',
  baud: 57600,
  signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]),
  productId: ['0x0037', '0x8037', '0x0036'],
  protocol: 'avr109',
  // or you can put it here:
  disableVerify: true
};


var avrgirl = new Avrgirl({
  board: board
});

Can I use avrgirl-arduino as a CLI tool?

You sure can!

Run npm install -g avrgirl-arduino in a shell session to install globally for easy CLI use.

The same example above would look like the following as a CLI call in your shell:

avrgirl-arduino flash -f Blink.cpp.hex -a uno

Required flags:

  • -f specify the location of the hex file to flash
  • -a specify the spcification of the Arduino. It can be:
    • the name of the Arduino (uno, mega,leonardo, micro, nano, "nano (new bootloader)", pro-mini, duemilanove168, yun, esplora, blend-micro, tinyduino, sf-pro-micro, qduino, pinoccio, feather, or imuduino)
    • a JavaScript file describing a custom board

When using a custom board, the JavaScript file must export the board specification:

var board = {
  name: 'micro',
  baud: 57600,
  signature: new Buffer([0x43, 0x41, 0x54, 0x45, 0x52, 0x49, 0x4e]),
  productId: ['0x0037', '0x8037', '0x0036'],
  protocol: 'avr109',
};

module.exports = board;

Optional flags:

  • -p will allow you to specify the port where your Arduino is plugged in. Remember to specify your port if using an Arduino Pro Mini.
  • -v will turn on debug/verbose mode, which will print a log of things when you run the command.

You can also list the supported boards:

avrgirl-arduino boards

As well as listing all available USB devices on your computer:

avrgirl-arduino list

The output will be presented in JSON format, very similar to the output of the Serialport.list() method (if you've used node-serialport before).

Custom board specification

When specifying a custom board object, a number of properties must be provided:

  • name: the name of the board, used in debug and error messages
  • baud: the data rate for data transmission
  • signature: a Buffer containing the device signature
  • productId: an array of valid USB product IDs for the board
  • protocol: the board communication protocol (avr109, stk500v1 and stk500v2 are currently supported)

If using the stk500v2 protocol, you also need to specify:

  • pageSize: the size of the page used to load programs

The other board specification properties are optional. You may look at boards.js for more details.

Sourcing a compiled Arduino hex file

A .hex file is the compiled end result of an Arduino sketch file. I have provided some example hex files for each board within the junk/hex folder of this repo. Feel free to use these, or if you're after something specific not provided, see the directions below.

The most common way to compile a sketch for your Arduino of choice is to download and install the Arduino IDE. Ensure you install version 1.6.5 or greater for the following steps.

  1. Open the sketch file you'd like to export, or write a new one if you need to.
  2. Choose the correct target Arduino board you want to compile the hex file for, from the Tools -> Board menu.
  3. Export your hex file by navigating to Sketch -> Export compiled binary screenshot of the Sketch menu in Arduino IDE with Export compiled binary menu item highlighted in blue
  4. You can find the exported hex file in the same directory your sketch file is located in.

Acknowledgements

Credit to Jacob Rosenthal, Ryan Day, and Elijah Insua for a lot of the heavy lifting going on underneath in this library.

Contributors

avrgirl-arduino's People

Contributors

ajfisher avatar algernon avatar alvarosbq avatar areksredzki avatar avalero avatar byronhulcher avatar dependabot[bot] avatar derekwheee avatar gratacos avatar greenkeeper[bot] avatar greenkeeperio-bot avatar hipsterbrown avatar jbrown123 avatar jonasbn avatar jordichauzi avatar lan-hekary avatar lisiadito avatar makenai avatar mcdonnelldean avatar mikeesto avatar monteslu avatar nandub avatar noopkat avatar reconbot avatar ryanbraganza avatar sandeepmistry avatar soryy708 avatar tocalvo avatar whitfin avatar wseng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

avrgirl-arduino's Issues

Investigate stk500v1 timeout with flashing uno on 5.2 OSX

NodeJS 5.x is not necessarily 'supported' at this stage, but this might be worth looking into.

notes: "after installing@latest with errors like... avrgirl-arduino flash -f /tmp/arduino_builds/BuiltInExcitment.ino.hex -a uno -p /dev/cu.usbmodem5D11 -v\nconnected\nreset complete.\nflashing, please wait...\nflash complete.\n[Error: Sending 6400804688e990e09f938f9382e093e09f938f930e94d30681e08a830f900f900f900f900f900f90df91cf910895cf93df93ec018f819885019721f4ce010e94680403c0ce010e9411048f819885df91cf9108950f931f93cf93df93ec018b014a960e94f003ce0140960e94f003ce010e94680481e08e878d871c861b86c80163e370e020: receiveData timeout after 400ms]\nmake: *** [avrdude] Error 1\n"

error: "no Arduino 'uno' found."
nodev: "5.2.0"
os: "darwin"
osv: "15.4.0" (El Capitan)
board: "uno"

github linked deps should be semver'd

Currently any updates to js-stk500v1 will be implicit updates in this project. This has the potential to break things, without any semver versioning to assist with rollbacks. Let's fix this, by either getting the github deps back to mainline, or pointing at specific SHAs instead of just branch names.

Align CLI functions with API?

Just noticed this in the readme:

avrgirl-arduino list

vs.

Avrgirl.listPorts(function(err, ports) {
...
});

I would happily submit a patch that aliases Avrgirl.list => Avrgirl.listPorts, if such a feature was desired. (Also can do on the other avrgirl-* modules)

Sparkfun Mega Pro Support

This is as easy as either adding a new board type or adding 0x6001 as a productId for 'mega'.
Settings are the same for this board as the mega.

Debug definition as function.

Very nice package.
I want to integrate it into my home automation platform ioBroker and found small problem.

It would be nice to have better integration possibilities. One of that is debug not to the console, but somewhere else.

this.debug = options.debug ? (typeof options.debug === 'function') ? options.debug : console.log.bind(console)) : function() {};

Flashing throws often a failure on RPi

First of all. Big thanks for this great work!

I have build an Plugin for Pimatic https://github.com/Icesory/pimatic-arduino-updater. When we run a flash process on an RPi often an Time out error occurs. This is testet with Nano328(CH340), Nano328(FT232RL), ProMini 5V328(FT232RL).

Most times this error occurs:

connected
reset complete.
flashing, please wait...
flash complete(red)
{ cause: [Error: Sending 3020: receiveData timeout after 400ms], isOperational: true}

Or this

connected
reset complete.
flashing, please wait...
flash complete(red)
{ cause: [Error: Sending 55001620: receiveData timeout after 400ms], isOperational: true}

This is an complete log from Pimatic with an other failure

22:31:55.805 [pimatic-arduino-updater] Start Arduino flash for homeduino
connected
reset complete.
flashing, please wait...
22:32:02.960 [pimatic] A uncaught exception occured: TypeError: Cannot call method 'toString' of undefined
22:32:02.960 [pimatic]>    at /home/pi/pimatic-app/node_modules/pimatic-arduino-updater/node_modules/avrgirl-arduino/node_modules/stk500/index.js:311:44
22:32:02.960 [pimatic]>    at /home/pi/pimatic-app/node_modules/pimatic-arduino-updater/node_modules/avrgirl-arduino/node_modules/stk500/lib/sendCommand.js:37:16
22:32:02.960 [pimatic]>    at finished (/home/pi/pimatic-app/node_modules/pimatic-arduino-updater/node_modules/avrgirl-arduino/node_modules/stk500/lib/receiveData.js:38:5)
22:32:02.960 [pimatic]>    at null._onTimeout (/home/pi/pimatic-app/node_modules/pimatic-arduino-updater/node_modules/avrgirl-arduino/node_modules/stk500/lib/receiveData.js:43:7)
22:32:02.960 [pimatic]>    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
22:36:24.314 [pimatic]> This is most probably a bug in pimatic or in a module, please report it!
22:36:24.360 [pimatic] shutting pimatic down...

The used node version is v0.10.24. On my dev machine (Ubuntu 14.04LTS) all works right. But on the RPi almost every flash throws an error. But in most times the Arduino is flashed with the given hexfile.

Any suggestions to isolate the failure?

Document the importance of Win drivers installation

Note: This issue is ideal for folks wishing to make their first code contribution/pull request to AVRGirl Arduino, or it might even be their first open source pull request ever! Please do not open a PR for this if you're an existing code/docs contributor to AVRGirl Arduino. Thanks ❀️


The Issue:

Plugging in an Arduino isn't an out-of-the-box-working experience for Windows users. Installing the Arduino IDE and the included drivers is an important first step before being able to use AVRGirl Arduino.

In the installation instructions, I'd love to see a small section in this project's README.md file added for Windows, with extra details documented on how to get the above 2 steps up and running.

There is already some great docs on how users can do this on this Arduino website page. It would be sufficient enough to share this link in the AVRGirl Arduino README, with some friendly language advising following only steps 1-4 is necessary. Keeping to the current writing personality/style of the README is encouraged.

Please follow the code contribution guidelines as set out in this repo's contributing guide.

Thank you @byronhulcher for reporting this via Test Pilot! ✨

Investigate STK500v1 issue on Node 0.10.x

One instance replicated as per Test Pilot report:

  • Linux
  • NodeJS 0.10.39
  • Uno board
  • Error: "no 'Uno' found"

Concerns:

  • Is this on Linux only, or all OS's affected for 0.10.x?
  • did the firmware still attempt upload?
  • is this isolated to stk500v1?

"Port is opening" error on Arduino nano

Hello,

I have been working with Avrgirl and the Arduino Uno without much issues, but when I try with an Arduino Nano, reading from the serial port fails.

I realise this might be somewhat outside of what Avrgirl is meant to be used for.

Basically, I am implementing a Serial Monitor, where I am able to choose which Serial Port to open. This works well for the Uno, but the Nano responds with a nasty "Port is open" exception. After that, however, the Serial communication is read, and everything seems to be working OK.

I've tried to debug, but I am not sure why this is happening on the Nano, and not the Uno.

This is the code I have for opening the serial port (I have tried openImmediately set to true as well):

`if (port) {
var serialPort = new SerialPort(port, {
baudrate: 9600,
openImmediately: false
}); // this is the openImmediately flag [default is true]

                selectedSerialPort = serialPort;
                serialPort.open(function (error) {
                    if (error) {
                        console.log('failed to open: ' + error);
                    } else {
                        console.log('open');
                        serialPort.on('data', function (data) {
                            //console.log('data received: ' + data);
                            serialDataCache = serialDataCache.concat(data);
                        });
                    }
                });
            }`

AVR109 verification fails on Linux

Flashing still effectively worked.

Replicated on an Arduino Micro with the returned error Flashed content length differs! local:128vs device: 1

Ability to specify custom board properties, or have the flashing process disregard 'incorrect' productIds

We're rolling our own hardware which has specs similar to the leonardo, so when flashing with the Arduino IDE we'll select that option. However we have a different productId to what's expected by the library, as specified in boards.js. Obviously with this set 'incorrectly' we'll hit Error: could not reconnect after resetting board. since the productId doesn't match what's expected.

It'd be great if we could pass an object when creating the Avrgirl instance that specifies the board properties (to pass our modified productId), or alternatively have the search process just check that it can connect to the comName specified in the 'port' property of the options object.

Or if the problem is that boards 'jump' comName's, given that we're selecting one we can search for it later with the productId, etc that it presented to us upon first list?

Command not found

I used the command sudo npm install avrgirl-arduino but when I try running the command avrgirl-arduino list I get an error saying -bash: avrgirl-arduino: command not found I ran npm init before running the first command and it still doesn't work.

Consider wording of project description

The project description confuses me.

An avrgirl-wrapper library for flashing Arduino microcontroller boards with NodeJS.

To me this sounds like a library that somehow puts NodeJS on Arduino boards, which leaves me at first amazed, then severely disappointed.

A clearer description could be:

An avrgirl-wrapper NodeJS library for flashing Arduino microcontroller boards.

Sourcing a Hex File

Since Arduino 1.6.5, there is a simpler method for exporting your hex file.

sketch > export binary
It it saved inside the sketch folder.

No longer have to search for random generated folder.

Testing with real hardware

My budget can't always support having every single Arduino on hand to test this with. I would love if anyone has matching hardware supported by avrgirl-arduino to verify that everything works well. I just recently busted my Arduino Mega's FTDI connection somehow, so this sort of thing becomes a problem for me to keep up with.

I mostly test with OSX (which is my dev machine). I have both Windows and Linux VM's that I use to test those platforms with, however these sometimes don't replicate a "real" machine experience. An example of this is due to using a modern.ie image for Windows, I can't get a realistic take on the automatic device driver installation workflow that Windows normally does. So! I would love if those with any platform could just give this library a go with any Arduino they have sitting around that is supported 😁

Successfully uploading a Blink.cpp.hex file is a great test to try. Included in this repo is a copy of a compiled and ready-to-flash Blink file for each supported device.

If you encounter any issues, please open a new issue on this repo describing what happened (errors, screenshots etc), or comment on an existing issue with a πŸ‘ if you spot a duplicate.

Thank you so much in advance πŸ™Œ

Board support: Pro Mini

This is a priority issue, in order to support @ajfisher's great work on his nodebots-interchange project.

A few things to consider here:

  • No reliable pid or vid, as the FTDI adaptor will most likely report itself instead. Brute force 'sign-on' attempts may be needed to attempt to get an expected answer back from one of the active ports.
  • Board reset method may differ depending on which FTDI adaptor is used (breakout board vs cable). Specifically this is pulling either the DTS or RTS low. More research to confirm this is needed.
  • Naming conventions so far has me leaning towards pro-mini as the string based identifier.
  • STK500v1 is the protocol to use for this board.

custom board object should be allowed to be sparse

Currently if you pass in a board object with only the name of the board in it, it breaks. Normally we'd want it to either error if missing vital props, or if the board object only contains the name, just merge it in with a default board object for the chosen board.

Board support: Pinoccio Scouts

Pinoccio Scouts use the stk500v2 protocol, which is supplied in avrgirl-arduino already. An addition to boards.js should be all that is required, with some testing with a real device. I no longer have a Scout to test with. Adding a precompiled version of both Standard Firmata and Blink sketches would also very much be appreciated.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Semantic Release

As mentioned in the stream, what do you think of using semantic-release in this repository?

I thought about doing it the following way:

Hooks could be run optionally by default (opt-in) and therefore be easier for new contributors to actually contribute.

Let me know your thoughts :)

Board Support: Sparkfun Pro Micro

Product link: https://www.sparkfun.com/products/12640 (there's also a 3V, 8MHz option)

I'm not sure why, but I bought this board a while ago on impulse when ordering other things. It's an interesting one. ATmega32U4 on board, so it's a Leonardo/avr109. But it seems to follow the Arduino Pro advantage of up to 16MHz and 12v. $20USD, not bad but twice the price of a Pro Mini.

Error ocurred on CLI mode

I used blew command to flash a demo, but error comes
$ avrgirl-arduino flash -f Blink.ino.eightanaloginputs.hex -a nano

/Users/xxx/.nvm/versions/node/v6.10.2/lib/node_modules/avrgirl-arduino/bin/cli.js:40
} else if (!boards.byName[argz.a]) {
^

TypeError: Cannot read property 'nano' of undefined
at handleInput (/Users/xxx/.nvm/versions/node/v6.10.2/lib/node_modules/avrgirl-arduino/bin/cli.js:40:32)
at Object. (/Users/xxx/.nvm/versions/node/v6.10.2/lib/node_modules/avrgirl-arduino/bin/cli.js:109:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:393:7)
at startup (bootstrap_node.js:150:9)

Support for devices that require a manual reset

Hi!

I'm working with a device (a Shortcut keyboard) that - at the moment at least - requires me to press a physical reset button on it, before I can flash a firmware. With avrdude, this causes no issues, but avrgirl wants to reset the device herself, and things fail horribly when I press the reset button while avrgirl is trying to reset it too.

Would it be possible to have a flag for the flash method to skip resetting the device, and just assume it is in a programmable state?

Serial read/write - 750ms delay necessary?

Somewhat an out-of-scope issue here, so I apologize if this is the wrong place for this, but I extended avrgirl-arduino to be able to send a message and wait for data back over serial, and it works beautifully. I hijack the automatic port finder and board validation to have a serialport instance ready to go before I send a message. Currently, I flashed one of our testing Arduino boards with an echo-echo Sketch, where it just spits back the data it reads over serial.

That said, I see an odd behaviour: I use a serialPort.on('data', function to wait for communications from the Arduino, but I have to wait approximately 750ms (minimum) after opening a connection before I can send a String over serial, and I can't do anything immediately after or the data coming back will be garbled.

Is this something you've noticed at all? Happy to provide code if you're interested in what I'm having it do, and I know it's outside of scope, just wondering if this is any behaviour you've seen before.

Thanks!

Flashing arduino pro micro fails

Flashing a basic hex file onto an arduino pro micro fails with "Error: could not reconnect after resetting board."
debug shows it finding the micro, and on the correct port.
debug then shows it resetting the board, and my pro micro does in fact reboot
then.... error, help!

Error: could not open board on ...

I'm trying to flash a (working and tested) hex file to a Pololu Zumo 32U4.
The first time it get stuck on:

found zumo on port /dev/cu.usbmodem1411
reset complete.
connected

When I reload the page (that forces the back end to try again) I get:

found zumo on port /dev/cu.usbmodem1411
reset complete.
Error: could not open board on /dev/cu.usbmodem1411
    at /Users/krille/Dropbox/Dev/robotkodarn/node_modules/avrgirl-arduino/lib/connection.js:152:15
    at next (/Users/krille/Dropbox/Dev/robotkodarn/node_modules/awty/index.js:39:11)
    at SerialPort.<anonymous> (/Users/krille/Dropbox/Dev/robotkodarn/node_modules/avrgirl-arduino/lib/connection.js:143:7)
    at SerialPort._error (/Users/krille/Dropbox/Dev/robotkodarn/node_modules/serialport/lib/serialport.js:148:14)
    at SerialPort.<anonymous> (/Users/krille/Dropbox/Dev/robotkodarn/node_modules/serialport/lib/serialport.js:172:19)

Note that I'm running the manualReset to true.

And by the way, the reason it says zumois because I've made a custom board:

var board = {
    name: 'zumo',
    baud: 57600,
    signature: new Buffer([0x1e, 0x95, 0x87]),
    productId: ['0x0036', '0x8036', '0x800c', '0x8036'],
    protocol: 'avr109'
}

var avrgirl = new Avrgirl({
    board: board,
    debug: true,
    manualReset: true
});

I've also tried using the leonardo that should be very alike and may also work (it works using the native Arduino app when compiling and uploading) but with no success.

Any ideas?

On Arduboy flashing fails with "Cannot open" or mid-flash inconsistently

Arduboy is a tiny gameboy-like device, based around the Arduino Leonardo. My dev kit has just arrived. It runs and flashes fine with the Arduino IDE, but with avrgirl-arduino I just couldn't get it to flash the generated hex.

It usually doesn't work, simply fails to access the device:

MacBooks-MacBook-Air:avrgirl-arduino flaki$ node bin/cli.js flash -f ~/Data/ArduBreakout/examples/ArduBreakout/ArduBreakout.cpp.leonardo.hex -a leonardo -v
found leonardo on port /dev/cu.usbmodem1411
resetting board...
Failed to connect: # 1
reset complete.
[Error: Cannot open /dev/cu.usbmodem1411]
MacBooks-MacBook-Air:avrgirl-arduino flaki$ 

(fwiw, the board does reset on every run of the above command, consistently).

Sometimes it then seems to work, but amidst flashing an error is thrown, and the device flash is left in a garbled state (that is, flashing overwrote some of the installed data, so the device wouldn't "start"). Reflashing with a separate tool (like Arduino IDE) "fixed" the state of the flash, so at least it doesn't brick the device or anything like that:

MacBooks-MacBook-Air:avrgirl-arduino flaki$ node bin/cli.js flash -f ~/Data/ArduBreakout/examples/ArduBreakout/ArduBreakout.cpp.leonardo.hex -a leonardo -v
found leonardo on port /dev/cu.usbmodem1411
resetting board...
Failed to connect: # 1
Failed to connect: # 2
reset complete.
connected
flashing, please wait...
/Users/flaki/Data/avrgirl-arduino/node_modules/chip.avr.avr109/chip.avr.avr109.js:156
        throw err;
              ^
Error: TODO: Start Linear Address Record
    at /Users/flaki/Data/avrgirl-arduino/node_modules/chip.avr.avr109/node_modules/intelhex/index.js:57:28
    at Array.forEach (native)
    at /Users/flaki/Data/avrgirl-arduino/node_modules/chip.avr.avr109/node_modules/intelhex/index.js:11:11
    at process._tickCallback (node.js:355:11)
MacBooks-MacBook-Air:avrgirl-arduino flaki$ 

add CLI features

  • avrgirl-arduino list - lists current serial ports available
  • avrgirl-arduino boards - lists currently supported boards

Human tester needed: Little Bits Arduino module

This fits into #5. I do not own any sets from Little Bits. I added support a while ago but cannot test it at the moment.

If anyone has this module, could they please compile some form of 'hello world' script for it (such as a blink sketch) and run the following code to see if it works as expected?

var Avrgirl = require('avrgirl-arduino');

var avrgirl = new Avrgirl({
  board: 'little-bits',
  debug: true
});

avrgirl.flash('Blink.cpp.hex', function (error) {
  if (error) {
    console.error(error);
  } else {
    console.info('done.');
  }
});

Thanks a million πŸ’›

Command not found

I used the command sudo npm install avrgirl-arduino but when I try running the command avrgirl-arduino list I get an error saying -bash: avrgirl-arduino: command not found I ran npm init before running the first command and it still doesn't work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.