ksksue / physicaloidlibrary Goto Github PK
View Code? Open in Web Editor NEWAndroid Library for communicating with physical-computing boards (e.g.Arduino, mbed)
Home Page: http://www.physicaloid.com/
Android Library for communicating with physical-computing boards (e.g.Arduino, mbed)
Home Page: http://www.physicaloid.com/
Hello,
I'm trying to use your lib in a phonegap/cordova plugin. So far the plumbing seems ok since I see the execution of my plugin, but I can connect to the serial port only a few times. I don't get what I'm doing wrong.
Here is the source: https://github.com/xseignard/cordovaSerial/blob/master/src/fr/drangies/cordova/serial/Serialoid.java
Any idea?
Regards
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
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.
The tutorial shows that it can upload compiled (.hex) files. Will it also work for .ino files? If not, how to upload that?
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
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...
I have problem, how to wait for user premission answer after call Physicaloid.open()?
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 ;
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 !
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!
when the count of files from SD Card on 3D printer is few, i can get all the correct file name of SD Card, but when the count of files from SD Card is many, i just get a part of file name , do you meet the same problem ? if you know that, please tell me
Hi!
I have a long time I can't overcome this problem. How to implement an infinite loop of reading serial monitor?
Can you please add a licence?
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.
Hi,
I am experiencing some difficulties with importing the library to Android Studio. Whenever I import it I get 2 errors:
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.
The FTDI driver only supports the first serial interface. This means multi-interface UART chips like the FT4232H are unsupported.
Is the Physicaloid Library available from maven central?
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?
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?
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.
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?
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();
}
Some Arduino Clones use CH340G Serial to USB Chips, with DTR pin also connected.
Could you take a look at the following drivers and add it to Physicaloid? That way we can upload HEX files using both CP chips and CH34x chips.
/usbserial/driver/Ch34xSerialDriver.java
/usbserial/CH34xSerialDevice.java
Update: This issue already has a solution here: xxxajk#2
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! :-)
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...
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 ?
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?
Hello friend, do you planing add WAVGAT arduino clone boerd?
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 */
}
I tried to connect device with my lenovo mobile using physicallibrary but Unable to connect , got the message "could not connect" and then System UI will stop working and phone gets locks
Hi ksksue (Keisuke SUZUKI), although my USB settings are correct Incorrect characters are being sent while printing data on the CP210x module.Mostly the character "?"
mPhysicaloid.write("test", buf.length);
the readlistener give to me "test".
How can i solve this problem. i hope you understand me.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.