Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with definition of variable in examplemultipleports #183

Open
W1il opened this issue Dec 20, 2018 · 2 comments
Open

Problem with definition of variable in examplemultipleports #183

W1il opened this issue Dec 20, 2018 · 2 comments
Assignees

Comments

@W1il
Copy link

W1il commented Dec 20, 2018

Hi, I want to modify the code of the examplemultipleports so that the parameters of the serial port can be variables that I can modify later, I have tried to declare it as variable (mConfigDataBit = DATA_BITS_7) but it always throws me error, someone can tell me what type of variable is DATA_BITS_8, DATA_BITS_7, DATA_BITS_6, DATA_BITS_5?

Here is my code:
`private int mConfigBaudRate;
private int mConfigDataBit = DATA_BITS_7 ;

private final BroadcastReceiver usbReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context arg0, Intent arg1) {
        if (arg1.getAction().equals(ACTION_USB_ATTACHED)) {
            boolean ret = builder.openSerialPorts(context, mConfigBaudRate,
                    UsbSerialInterface.mConfigDataBit,
                    UsbSerialInterface.STOP_BITS_1,
                    UsbSerialInterface.PARITY_NONE,
                    UsbSerialInterface.FLOW_CONTROL_OFF);
            if(!ret)
                Toast.makeText(context, "Couldnt open the device", Toast.LENGTH_SHORT).show();

`
Regards

@felHR85
Copy link
Owner

felHR85 commented Dec 20, 2018

@W1il What kind of error is throwing?

@W1il
Copy link
Author

W1il commented Dec 20, 2018

Hi felHR85,

Thanks I already solutions that problem, now I have another, when I open the application and connect the USB cable, the application works but if for some reason I disconnect the USB cable and again connect it the application no longer runs for more attempts to make connect and disconnect the usb cable until the application finishes and again open it, there is some way to change this so that each time the USB cable is connected the application is reinitialized (both the MainActivity and the UsbService).

Regards

@felHR85 felHR85 self-assigned this Dec 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants