BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/index.php)
-   Developer Forum (http://www.blackberryforums.com/forumdisplay.php?f=15)
-   -   USB connection using stream level API (http://www.blackberryforums.com/showthread.php?t=226106)

Galian 05-07-2010 11:17 PM

USB connection using stream level API
 
Hi all,

I'm new to BlackBerry programming, and I need your advise my friends...

I'm trying to establish USB connection between desktop and my device. I'm using JDK 4.7.

As we know it's to ways to establish connection through USB:

1. Using stream connection (Connector.open(...))

2. Using low-level API (USBPort)

I tried both ways, and I found problems in both situations:

1. Using first method we have stream functionality, and this is definitely advantage, but I can't figure out, how can I handle that connection was established? We are calling Connector.open, and have as a return value valid StreamConnection object, than we are opening streams, and also have valid objects. It's no any analogue like AcceptAndOpen or something similar... One way that I see in this situation, is to open channel using connector, and than wait on blocking read on input stream, but this is workaround, and I don't really want to use it, because when you writing echo server for demonstration - it's one thing, but if you writing full functional system, it's quite different.

2. This method (low level) full opposite to first - you have a lot of control (callbacks using USBPortListener, writing/reading, etc), but in return, you should handle a lot of things manually, like for example: to send/receive big packets of data you should care about buffering, implementing receiving/sending is robust, because you should not only call read/write function, but you should handle callbacks like dataSent/dataReceived and so on, besides you should correctly handle all callbacks. And when you try to implement all this stuff, synchronize it, you starting to think something like "It should be something here another, simple solution, I need just to find it...".

So, the question: is it some possibility when we are using stream level API, to know that connection is established? Synchronous/asynchronous - doesn't matter. Or may be you know some other ways how to connect using USB without all these unneeded stuff?


Thank you in advance!


All times are GMT -5. The time now is 09:57 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.