Back to project page HRCF--Hermes-RC-Framework-.
The source code is released under:
GNU Lesser General Public License
If you think the Android project HRCF--Hermes-RC-Framework- listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.rathole.android.hermesRC; // w ww . j a v a2 s . c o m import java.io.IOException; import android.app.Application; import android.content.Context; import android.hardware.usb.UsbManager; import android.util.Log; import com.hoho.android.usbserial.driver.UsbSerialDriver; import com.hoho.android.usbserial.driver.UsbSerialProber; public class USB_serial extends Application{ private UsbManager manager; private UsbSerialDriver driver; public void begin(int baudrate){ this.manager = (UsbManager) getSystemService(Context.USB_SERVICE); this.driver = UsbSerialProber.acquire(manager); if (driver != null) { //USB Driver Check & Serial Initialize. try{ this.driver.open(); this.driver.setBaudRate(baudrate); }catch(IOException e){ Log.d("Err", "Driver");}} } public void print(byte buf[],int length) { try{ this.driver.write(buf,length); }catch(IOException e){} } public void close() { try{ this.driver.close(); }catch(IOException e){} } }