GithubHelp home page GithubHelp logo

ksksue / physicaloidlibrary Goto Github PK

View Code? Open in Web Editor NEW
354.0 354.0 151.0 1.13 MB

Android Library for communicating with physical-computing boards (e.g.Arduino, mbed)

Home Page: http://www.physicaloid.com/

Groovy 0.39% CSS 3.65% Java 95.96%

physicaloidlibrary's People

Contributors

ksksue avatar lauszus 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

physicaloidlibrary's Issues

STK500.getsync() : not in sync: resp=0x00

while uploading hex file to 'Arduino Uno CH340',
error Can't open connection to MCU occured.

Two out of 30 get this error.

However, it worked fine when I used another app that uploaded hex files.

get log message

recv timeout.
STK500.getsync() : not in sync: resp=0x00
recv timeout.
STK500.getparm() : (a) protocol error, expect=0x14, resp=0x41
[ 09 - 06 18:55:20.888  825:   849 D/             ]
DpmQmiMgr areAllIfaceActive
recv timeout.
STK500.getparm() : (a) protocol error, expect=0x14, resp=0x41
recv timeout.
STK500.initialize() : (a) protocol error, expect=0x14, resp=0x42

Asynchronous reading from the Arduino

I'd noticed that while my writes to an arduino seemed to be pretty quick, my reads are not. It seems that I needed to somewhere around 100ms before I consistently have good read results. Since I'm working on an app that needs bidirectional communication with the arduino at around 20Hz (or faster), this is an issue.

Looking at the cdc driver, it seems like you implement reading in a thread which does the usb bulk transfer every 50ms. Is there a reason 50ms was chosen? Would I run into issues if I modified it to run faster? Where is the com.ftdi.j2xx driver referenced in physicaloid? Why have reads by synchronous (though hidden from the user) while writes are truly asynchronous?

Having a 50ms wait time for a read seems at odds with the idea of providing an interface to physical computing boards.

How to handle .ino files?

The tutorial shows that it can upload compiled (.hex) files. Will it also work for .ino files? If not, how to upload that?

Could not create plugin of type 'LibraryPlugin' while building code

Hi Thanshon ,

Hope you are doing well.

I am working for an open source NGO project for students learning using code without coding block based programming.
The requirement to burn code into a physical device i.e Arduino Uno board using a mobile device stuck for me.

I found your source code is on older version not able to compile doing the same feature hex file select and upload . Can you help me how you import the library and design to upload code .

can you help me on this please on steps to build your git hub code .

_Failed to apply plugin 'android-library'.

Could not create plugin of type 'LibraryPlugin'.
> Could not generate a decorated class for type LibraryPlugin.
> org/gradle/api/artifacts/result/ResolvedModuleVersionResult_

Regards
Ayushi Mundra

Cannot Open

Dear admin:
Sorry to bother i am a newbie here. Currently trying to send my data from Arduino Mega to Andriod Samsung S2 via USB.

Does anyone face any problem while using Physicaloid library where the device is set not to open at all time?
Why i keep receiving the "Cannot Open" message even when i didnt even change anything in the code.
I am even try all the tutorial example in this library but all also give the same message "Cannot Open". Is there anything that need to be aware when importing the library?

Any Advice is welcome...

How to use this library into a project

Hi,
I'm trying to use this library in one of my project but I'm stuck.
I'm trying to putting it into Android Studio (latest)

Unfortunately I don't see how I can do it. I read your ReadMe ;

  1. File -> import and select a PhysicaloidLibrary directory.
  2. Right click your project -> Properties -> Android -> click Library's "Add" button -> select PhysicaloidLibrary

But I have not the File -> import.
And no properties when right clicking on my project.
( pics attached)

In fact, most of the time I'm using github projects which have a release. It's an easiest way to import it ;).

So, can you explain me how can I install it in Android Studio ? Or can you make a release ?

Thank you a lot and sorry for my english !

firststep
secondstep

USB host permissions with Android 9 (Pie)

I am trying to use an Arduino with a rooted Xiamo Pocophone F1 flashed with LineageOS 16. I am struggling how to get the user permission for USB host mode. I just don't know how to do it. Can someone help? Plugging the Arduino does not create an intent, so getting the permission on the fly does not seem to work. And I don't know the explicit "name" of the permission. So I don't know what to query. Thanks!

infinite read cycle

Hi!
I have a long time I can't overcome this problem. How to implement an infinite loop of reading serial monitor?

Want to interface two cp210x module

I want to interface two cp210x using usb2.0 hub. How to communicate with both independently. Is their solution to do it with physicaloid library.

Guidelines for importing library to Android Studio

Hi,
I am experiencing some difficulties with importing the library to Android Studio. Whenever I import it I get 2 errors:

  1. all of a sudden ActionBarActivity cannot be resolved
  2. I get gradle error: "Error:The SDK Build Tools revision (18.1.0) is too low for project ':PhysicaloidLibrary'. Minimum required is 19.1.0" even tough SDK Build Tools revison 19.1.0 (and higer) are all installed. I also looked in every possible gradle file and I haven't been able to found any reference to numbers 18.1.0 nor 19.1.0

I don't know if there is an issue with configuration of my parent project or the issue arises from the fact that this project was developed in Eclipse and has a different file structure. When I create a new project I set the minSDK to 12 since USB Host mode is only part of Android 3.1+.

It would be nice if there would be a tutorial for importing into Android Studio since it is now the official IDE. I am willing to create a tutorial with screenshots and everything, it's just I cannot resolve the problem.

Any help is much appreciated.

Maven Central

Is the Physicaloid Library available from maven central?

Usage with ArduinoISP

The functions are based around Board definitions. In my case I need to program via a separate programmer, if this is supported, I cannot track it down. Is this feature supported?

Reconnecting Crashes app

Disconnecting an open device and then reconnecting the same device to the tablet crashed the application. Doesn't anyone know of a way to automatically close/disconnect the usb device and automatically open/connect the usb device?

Cannot Open

Dear admin:

I also have the same problem " Cannot Open ". I downloaded the old version physicaloidlibrary.jar to replace the origin one. And I import physicaloid library. It seem worked for first try. But when I close eclipse and retry, I find the it will generate the original physicaloidlibrary.jar and replace the old version one and it will " Cannot Open ".again... How can I fix this?

Thank you very much.

Connection doesn't open

I am trying to convert project using the old FTDriver library to the Physicaloid library but i cannot get it to open a connection. USB permission pops up for the app and select allow but it never opens the connection to the attached device. Also, none of the tutorials will connect to my Arduino either when compiled with the Physicaloid library.

I have even tried compiling the Serial monitor lite with the Physicaloid library downloaded from here, also won't connect to the Arduino ("Cannot connect") . Though when I try the one from the app store it works fine.

Not sure if this is due to the latest library update?

mPhysicaloid.open() never open

I start use this library in my project two months ago, it worked very well, but yesterday the library stop work, in this condition "if(mPhysicaloid.open())" don't open, i don't know why this happen.

My manifest code

<uses-feature android:name="android.hardware.usb.host" />

<activity
        android:name=".view.MainActivity"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
        </intent-filter>
        <meta-data
            android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
            android:resource="@xml/device_filter" />
    </activity>

My Activity code

 mPhysicaloid = new Physicaloid(this);
    if (mPhysicaloid.open()) {
        Toast.makeText(context, "USB Conection Open", Toast.LENGTH_LONG).show();
        String str = dataToSend + "\r\n";
        byte[] buf = str.getBytes();
        mPhysicaloid.write(buf, buf.length);
    } else {
        Toast.makeText(context, "Error Open USB Conection", Toast.LENGTH_LONG).show();
    }

Standard Java Streams Please

Many J libs (including mine) are designed around standard Java IO streams. If you equip this lib with InputStream and OutputStream interfaces (the English word, not the Java term), and make the throughput efficient and low-latency, high-bandwidth, it'll become extremely popular! Do it! :-)

Wonder What makes physicaloid.open() fail

Hello :)
I tested with node mcu(with cp2102) and works quite well.
but I made custom pcb with cp2102 and usb-c .
when I attach it to my phone,
my custom pcb is wired like
cp2102's D+ and D- is connected to usb-c 's D+ and D-
and cp2102 ' rx tx is connected to mcu's tx,rx

I connect my custom pcb to phone and it detects cp2102 well as code below.

UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
        HashMap<String, UsbDevice> deviceList = manager.getDeviceList();

and I open physicaloid as below

    mPhysicaloid = new Physicaloid(mContext);
    mPhysicaloid.setBaudrate(9600);
    mPhysicaloid.open();

if (mPhysicaloid.isOpened()) {
//success
//when I tested with node mcu, it always success
}else{
//failed
//but with my custom pcb with cp2102 and usb-c keep failed.
}

I don't get it why mPhysicaloid is not opened...

ftdi d2xx -> Android error, def not found

Hi, I've been using Physicaloid and it worked fine for a project of mine. Then (using the same USB device), I import the library, like I always do, and I have an error when I connect my USB device.

The app crashes, and I got an error : "NoClassDefFoundError: failed resolution of : Mcom/ftdi/j2xx/d2xxManager"

I can see the d2xx jar in lib folder, I've added everything I know to make it work -> Still got the error.

Any help ?

PhysicaloidLibrary read data.

Hellow.
On Arduino UNO i read data(use FTD library) like this

StringBuilder mText = new StringBuilder();
FTDriver mSerial = new FTDriver((UsbManager)getSystemService(Context.USB_SERVICE));
PendingIntent permissionIntent = PendingIntent.getBroadcast( this, 0,
new Intent(ACTION_USB_PERMISSION), 0);
mSerial.setPermissionIntent(permissionIntent);

int i,len;
byte[] rbuf = new byte[4096];
len = mSerial.read(rbuf);
if (len>0){
for(i=0; i<len; i++) {
mText.append((char) rbuf[i]);
}

It's work great.
But when i try read data use PhysicaloidLibrary

private int mBaudrate = 9600;
private int mDataBits = UartConfig.DATA_BITS8;
private int mParity = UartConfig.PARITY_NONE;
private int mStopBits = UartConfig.STOP_BITS1;
StringBuilder mText = new StringBuilder();

Physicaloid mPhysicaloid = new Physicaloid(this);
mPhysicaloid.open();
mPhysicaloid.setConfig(new UartConfig(mBaudrate, mDataBits, mStopBits, mParity, false, false));

int i,len;
byte[] rbuf = new byte[4096];
len = mPhysicaloid.read(rbuf);
if (len>0){
for(i=0; i<len; i++) {
mText.append((char) rbuf[i]);
}

it does not work.
But write data using both library is no problem. Everything works.
Tell me please, why the data can not be read using PhysicaloidLibrary?

Problem with . open() running only once.

Hi,
I encounter this annoying result: the open method executed just once.
The resulting part of the code "Do actions" would only be performed once because mPhysicaloid no longer wants to open.

mPhysicaloid = new Physicaloid(mContext);
if (!mPhysicaloid.isOpened()) { /* if not opened */
    if(mPhysicaloid.open()){
       /* open connection */
    }
}
if (mPhysicaloid.isOpened()) {
    /* Do actions */
}

Callback Off

Hi. My question is .
When i send the data mPhysicaloid.addReadListener is handled it.
for example

mPhysicaloid.write("test", buf.length);

the readlistener give to me "test".

How can i solve this problem. i hope you understand me.

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.