当前位置: 首页>>代码示例>>Java>>正文


Java D2xxManager.D2xxException方法代码示例

本文整理汇总了Java中com.ftdi.j2xx.D2xxManager.D2xxException方法的典型用法代码示例。如果您正苦于以下问题:Java D2xxManager.D2xxException方法的具体用法?Java D2xxManager.D2xxException怎么用?Java D2xxManager.D2xxException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ftdi.j2xx.D2xxManager的用法示例。


在下文中一共展示了D2xxManager.D2xxException方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: UartFtdi

import com.ftdi.j2xx.D2xxManager; //导入方法依赖的package包/类
public UartFtdi(Context context) {
    super(context);
    mContext = context;
    mReadThreadStop = true;
    mUartConfig = new UartConfig();
    mBuffer = new RingBuffer(RING_BUFFER_SIZE);
    try {
        ftD2xx = D2xxManager.getInstance(mContext);
    } catch (D2xxManager.D2xxException ex) {
        Log.e(TAG, ex.toString());
    }
}
 
开发者ID:cattaka,项目名称:PhysicaloidVc,代码行数:13,代码来源:UartFtdi.java

示例2: onStartCommand

import com.ftdi.j2xx.D2xxManager; //导入方法依赖的package包/类
@Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        if (mIsRunning) {
            Log.i(TAG, "Service already running.");
            return Service.START_REDELIVER_INTENT;
        }

        mUsbDevice = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);

        if (null == ftD2xx) {
            try {
                ftD2xx = D2xxManager.getInstance(this);
                ftD2xx.createDeviceInfoList(this);

            } catch (D2xxManager.D2xxException ex) {
                Log.e(TAG, ex.getMessage(), ex);
            }

        }

        // connect
        if (null == ftDevice)
        {
            ftDevice = ftD2xx.openByUsbDevice(this, mUsbDevice);
        }


        if (ftDevice == null || !ftDevice.isOpen()) {
            Log.e(TAG, "Opening ftDevice Failed");
            stopSelf();
            return Service.START_REDELIVER_INTENT;
        }

        ftDevice.setBitMode((byte) 0, D2xxManager.FT_BITMODE_RESET);
        ftDevice.setBaudRate(baudRate);

        ftDevice.setDataCharacteristics(dataBit, stopBit, parity);

        ftDevice.setFlowControl(flowControl, (byte) 0x0b, (byte) 0x0d);

        ftDevice.purge((byte) (D2xxManager.FT_PURGE_TX));

        Log.d(TAG, "LATENCY_TIMER: " + ftDevice.getLatencyTimer());
//        ftDevice.setLatencyTimer((byte) 200);

        ftDevice.restartInTask();

        mIsRunning = true;

        Log.i(TAG, "Receiving!");
        Toast.makeText(getBaseContext(), getString(R.string.receiving), Toast.LENGTH_SHORT).show();
        startReceiverThread();
        startSenderThread();

        return Service.START_REDELIVER_INTENT;
    }
 
开发者ID:florian-f,项目名称:braindroid,代码行数:58,代码来源:BrainDroidService.java

示例3: UartFtdi

import com.ftdi.j2xx.D2xxManager; //导入方法依赖的package包/类
public  UartFtdi(Context context) {
    super(context);
    mContext = context;
    mReadThreadStop = true;
    mUartConfig = new UartConfig();
    mBuffer = new RingBuffer(RING_BUFFER_SIZE);
    try {
        ftD2xx = D2xxManager.getInstance(mContext);
    } catch (D2xxManager.D2xxException ex) {
        Log.e(TAG,ex.toString());
    }
}
 
开发者ID:RobotPajamas,项目名称:SimpleUSB,代码行数:13,代码来源:UartFtdi.java

示例4: UartFtdi

import com.ftdi.j2xx.D2xxManager; //导入方法依赖的package包/类
public UartFtdi(Context context) {
    super(context);
    mContext = context;
    mReadThreadStop = true;
    mUartConfig = new UartConfig();
    mBuffer = new RingBuffer(RING_BUFFER_SIZE);
    try {
        ftD2xx = D2xxManager.getInstance(mContext);
    } catch (D2xxManager.D2xxException ex) {
        Log.e(TAG,ex.toString());
    }
}
 
开发者ID:guiruiz,项目名称:Twiteckon,代码行数:13,代码来源:UartFtdi.java

示例5: serial_initialize

import com.ftdi.j2xx.D2xxManager; //导入方法依赖的package包/类
public void serial_initialize()                                                                 // Initialize all serial communication items
{

	try
	{
		ftD2xx = D2xxManager.getInstance(this);
	} catch (D2xxManager.D2xxException e)
	{
		Log.e("FTDI_HT", "getInstance fail!!");
	}


	global_context = this;

	// init modem variables
	modemReceiveDataBytes = new int[1];
	modemReceiveDataBytes[0] = 0;
	modemDataBuffer = new byte[MODEM_BUFFER_SIZE];
	zmDataBuffer = new byte[MODEM_BUFFER_SIZE];

	// file explore settings:
	fileDialog = new SelectFileDialog(this, handler, mPath);
	fileDialog.setCanceledOnTouchOutside(false);
	fileDialog.addFileListener(new SelectFileDialog.FileSelectedListener() {
		public void fileSelected(File file) {
			Log.d(getClass().getName(), "selected file " + file.toString());
			fGetFile = file;
		}
	});


	//readText = (TextView) findViewById(R.id.ReadValues);


	/* allocate buffer */
	writeBuffer = new byte[512];
	readBuffer = new byte[UI_READ_BUFFER_SIZE];
	readBufferToChar = new char[UI_READ_BUFFER_SIZE];
	readDataBuffer = new byte[MAX_NUM_BYTES];
	actualNumBytes = 0;

	// start main text area read thread
	handlerThread = new HandlerThread(handler);
	handlerThread.start();

	/* setup the baud rate list*/
	baudAdapter = ArrayAdapter.createFromResource(this,
			R.array.baud_rate_1, R.layout.my_spinner_textview);
	baudAdapter.setDropDownViewResource(R.layout.my_spinner_textview);
	baudRate = 115200;

	/* stop bits */
	ArrayAdapter<CharSequence> stopAdapter = ArrayAdapter.createFromResource(this,
			R.array.stop_bits, R.layout.my_spinner_textview);
	stopAdapter.setDropDownViewResource(R.layout.my_spinner_textview);
	stopBit = 1;

	/* data bits */
	ArrayAdapter<CharSequence> dataAdapter = ArrayAdapter.createFromResource(this,
			R.array.data_bits, R.layout.my_spinner_textview);
	dataAdapter.setDropDownViewResource(R.layout.my_spinner_textview);
	dataBit = 8;

	/* parity */
	ArrayAdapter<CharSequence> parityAdapter = ArrayAdapter.createFromResource(this,
			R.array.parity, R.layout.my_spinner_textview);
	parityAdapter.setDropDownViewResource(R.layout.my_spinner_textview);
	parity = 0;

	/* flow control */
	ArrayAdapter<CharSequence> flowAdapter = ArrayAdapter.createFromResource(this,
			R.array.flow_control, R.layout.my_spinner_textview);
	flowAdapter.setDropDownViewResource(R.layout.my_spinner_textview);
	flowControl = 1;

	/* port */
	portAdapter = ArrayAdapter.createFromResource(this, R.array.port_list_1,
			R.layout.my_spinner_textview);
	flowAdapter.setDropDownViewResource(R.layout.my_spinner_textview);
	portIndex = 0;
}
 
开发者ID:atarek92,项目名称:Intelligent_Indoor_Localization_System,代码行数:82,代码来源:J2xxHyperTerm.java

示例6: openUsbConnection

import com.ftdi.j2xx.D2xxManager; //导入方法依赖的package包/类
@Override
protected void openUsbConnection() throws IOException {
	D2xxManager ftD2xx = null;
	try {
		ftD2xx = D2xxManager.getInstance(mContext);
	} catch (D2xxManager.D2xxException ex) {
		mLogger.logErr(TAG, ex);
	}

	if (ftD2xx == null) {
		throw new IOException("Unable to retrieve D2xxManager instance.");
	}

	int DevCount = ftD2xx.createDeviceInfoList(mContext);
	Log.d(TAG, "Found " + DevCount + " ftdi devices.");
	if (DevCount < 1) {
		throw new IOException("No Devices found");
	}

	try {
		// FIXME: The NPE is coming from the library. Investigate if it's
		// possible to fix there.
		ftDev = ftD2xx.openByIndex(mContext, 0);
	} catch (NullPointerException e) {
		Log.e(TAG, e.getMessage(), e);
	} finally {
		if (ftDev == null) {
			throw new IOException("No Devices found");
		}
	}

	Log.d("USB", "Opening using Baud rate " + mBaudRate);
	ftDev.setBitMode((byte) 0, D2xxManager.FT_BITMODE_RESET);
	ftDev.setBaudRate(mBaudRate);
	ftDev.setDataCharacteristics(D2xxManager.FT_DATA_BITS_8, D2xxManager.FT_STOP_BITS_1,
			D2xxManager.FT_PARITY_NONE);
	ftDev.setFlowControl(D2xxManager.FT_FLOW_NONE, (byte) 0x00, (byte) 0x00);
	ftDev.setLatencyTimer(LATENCY_TIMER);
	ftDev.purge((byte) (D2xxManager.FT_PURGE_TX | D2xxManager.FT_PURGE_RX));

	if (!ftDev.isOpen()) {
		throw new IOException();
	} else {
		Log.d("USB", "COM open");
	}
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:47,代码来源:UsbFTDIConnection.java

示例7: open

import com.ftdi.j2xx.D2xxManager; //导入方法依赖的package包/类
@Override
public boolean open() {
    if (ftD2xx == null) {
        try {
            ftD2xx = D2xxManager.getInstance(mContext);
        } catch (D2xxManager.D2xxException ex) {
            Log.e(TAG, ex.toString());
            return false;
        }
    }

    if (ftDev == null) {
        int devCount = 0;
        devCount = ftD2xx.createDeviceInfoList(mContext);

        if (DEBUG_SHOW) {
            Log.d(TAG, "Device number : " + Integer.toString(devCount));
        }

        D2xxManager.FtDeviceInfoListNode[] deviceList = new D2xxManager.FtDeviceInfoListNode[devCount];
        ftD2xx.getDeviceInfoList(devCount, deviceList);

        if (devCount <= 0) {
            return false;
        }

        ftDev = ftD2xx.openByIndex(mContext, USB_OPEN_INDEX);
    } else {
        if (ftD2xx.createDeviceInfoList(mContext) > 0) {
            synchronized (ftDev) {
                ftDev = ftD2xx.openByIndex(mContext, USB_OPEN_INDEX);
            }
        }
    }

    if (ftDev.isOpen()) {
        synchronized (ftDev) {
            ftDev.resetDevice(); // flush any data from the device buffers
        }
        setBaudrate(mUartConfig.baudrate);
        if (DEBUG_SHOW) {
            Log.d(TAG, "An FTDI device is opened.");
        }
        startRead();
        return true;
    } else {
        if (DEBUG_SHOW) {
            Log.e(TAG, "Cannot open an FTDI device.");
        }
    }
    return false;
}
 
开发者ID:cattaka,项目名称:PhysicaloidVc,代码行数:53,代码来源:UartFtdi.java

示例8: open

import com.ftdi.j2xx.D2xxManager; //导入方法依赖的package包/类
@Override
public boolean open() {
    if(ftD2xx == null) {
        try {
            ftD2xx = D2xxManager.getInstance(mContext);
        } catch (D2xxManager.D2xxException ex) {
            Log.e(TAG,ex.toString());
            return false;
        }
    }

    if(ftDev == null) {
        int devCount = 0;
        devCount = ftD2xx.createDeviceInfoList(mContext);

        if(DEBUG_SHOW) {Log.d(TAG, "Device number : "+ Integer.toString(devCount)); }

        D2xxManager.FtDeviceInfoListNode[] deviceList = new D2xxManager.FtDeviceInfoListNode[devCount];
        ftD2xx.getDeviceInfoList(devCount, deviceList);

        if(devCount <= 0) {
            return false;
        }

        ftDev = ftD2xx.openByIndex(mContext, USB_OPEN_INDEX);
    } else {
        if (ftD2xx.createDeviceInfoList(mContext) > 0) {
            synchronized(ftDev) {
                ftDev = ftD2xx.openByIndex(mContext, USB_OPEN_INDEX);
            }
        }
    }

    if(ftDev.isOpen()) {
        synchronized(ftDev) {
            ftDev.resetDevice(); // flush any data from the device buffers
        }
        setBaudrate(mUartConfig.baudrate);
        if(DEBUG_SHOW){ Log.d(TAG, "An FTDI device is opened."); }
        startRead();
        return true;
    } else {
        if(DEBUG_SHOW){ Log.e(TAG, "Cannot open an FTDI device."); }
    }
    return false;
}
 
开发者ID:RobotPajamas,项目名称:SimpleUSB,代码行数:47,代码来源:UartFtdi.java


注:本文中的com.ftdi.j2xx.D2xxManager.D2xxException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。