ksksue / PhysicaloidLibrary

Android Library for communicating with physical-computing boards (e.g.Arduino, mbed)
http://www.physicaloid.com/
357 stars 151 forks source link

Gradle update and added support for Balanduino #3

Closed Lauszus closed 11 years ago

Lauszus commented 11 years ago

Create build.gradle in root of project, so the entire project can be build at once.

Lauszus commented 11 years ago

I also added support for the Balanduino: http://balanduino.net/. It uses the ATmega1284P. Also please tell me if you want me to send you the "serialtest.balanduino.hex" ;)

Lauszus commented 11 years ago

I will add something like this: https://github.com/TKJElectronics/BalanduinoAndroidApp/blob/ce14dd02327acc125d70e901945566c8900ed666/src_usb/Upload.java#L37-L80 to the library as well, so it won't try to open the connection if it hasn't got permission yet. I believe it would be best to add it to AutoCommunicator: https://github.com/Lauszus/PhysicaloidLibrary/blob/master/PhysicaloidLibrary/src/com/physicaloid/lib/framework/AutoCommunicator.java.

Lauszus commented 11 years ago

Also I get an "Illegal .hex file." when trying to upload a large .hex file. I will try to fix that as well.

ksksue commented 11 years ago

I will add something like this: https://github.com/TKJElectronics/BalanduinoAndroidApp/blob/ce14dd02327acc125d70e901945566c8900ed666/src_usb/Upload.java#L37-L80 to the library as well, so it won't try to open the connection if it hasn't got permission yet. I believe it would be best to add it to AutoCommunicator: https://github.com/Lauszus/PhysicaloidLibrary/blob/master/PhysicaloidLibrary/src/com/physicaloid/lib/framework/AutoCommunicator.java.

It's good idea. I check permission here https://github.com/ksksue/PhysicaloidLibrary/blob/master/PhysicaloidLibrary/src/com/physicaloid/lib/usb/UsbAccessor.java#L79-92 but it doesn't have a broadcast.

So my code tap upload->dialog "USB Permission?"->yes->do nothing->tap upload-> upload your code tap upload->dialog"USB Permission?"->yes->upload Right?

I think it's good that there are onPermissionAllowed/onPermissionDenied callback methods. User can write re-upload or just re-open.

Lauszus commented 11 years ago

Yes that is right. Mine will ask for permission if it hasn't got it already and then wait until the user allows it. Okay I will implement those callbacks then :)

I can't figure out why my .hex file for my code for my robot: https://github.com/TKJElectronics/Balanduino/tree/master/Firmware/Balanduino doesn't work. I have tried both compiling it using the Arduino IDE and a Makefile I have, but both of them simply just returns: "Illegal .hex file.".

Lauszus commented 11 years ago

I looks like it is triggered every time the size get's over 16 bits (65536). There must be a 16 bits variable somewhere that needs to be 32 bits instead.

Lauszus commented 11 years ago

I'm still getting "java.lang.Exception: EXT_SEG record not implemented", so it's failing here: https://github.com/ksksue/PhysicaloidLibrary/blob/master/PhysicaloidLibrary/src/cz/jaybee/intelhex/IntelHexParser.java#L146. Do you know how to fix this?

Lauszus commented 11 years ago

I thought I could solve it by increasing this value: https://github.com/ksksue/PhysicaloidLibrary/blob/master/PhysicaloidLibrary/src/com/physicaloid/lib/programmer/avr/IntelHexFileToBuf.java#L61, but that doesn't work.

Lauszus commented 11 years ago

I looks like I need to implement "Extended Segment Address Record" - source: http://en.wikipedia.org/wiki/Intel_HEX.

Lauszus commented 11 years ago

I found this C++ file that might help: https://github.com/codinghead/Intel-HEX-Class/blob/master/intelhex_class/intelhexclass.cpp#L510

Lauszus commented 11 years ago

I believe I got it working by adding:

case EXT_SEG:
    if (record.length == 2) {
        upperAddress = ((record.data[0] & 0xFF) << 8) + (record.data[1] & 0xFF);
        upperAddress <<= 4; // ESA is bits 4-19 of the segment base address (SBA), so shift left 4 bits
    } else {
        throw new Exception("Invalid EXT_SEG record (" + recordIdx + ")");
    }
    break;

But I will have to test to see if there are any problems with it.