开发者

communication of devices using serial port in java

开发者 https://www.devze.com 2023-03-02 09:16 出处:网络
开发者_Python百科 How to do this kind of communication? What libraries are available? How isthe data seen as bits?
    开发者_Python百科
  • How to do this kind of communication?
  • What libraries are available?
  • How is the data seen as bits?


Serial on Java is a bit tricky to get started, but once you've got it up and running, it's quite straightforward.

Serial is not implemented in a uniform way on different OS's, so Sun's approach was to develop the JavaComm specification and a reference implementation. For better or worse, Sun appeared to lose interest several years ago, and dropped Windows support in 2005.

So, the reference implemetation has largely been 'superceded' by a project called RXTX. RXTX works with Windows, Linux, BSD, Mac etc, so this is normally reason enough to use it.

Both these implementations require use of a native library (.so or .dll), which needs to be installed & configured in a per-platform way.

See this link for a balanced introduction, including code samples: http://en.wikibooks.org/wiki/Serial_Programming/Serial_Java

Here is the RXTX project: http://rxtx.qbang.org/wiki/index.php/Main_Page

HTH

Edit: in answer to your final question, the javacomm SerialPort class provides getInputStream() and getOutputStream() methods, so you can use these as you normally would in java.io


Java Communications API.

Starting here might get to you info you need:

http://www.oracle.com/technetwork/java/index-jsp-141752.html

0

精彩评论

暂无评论...
验证码 换一张
取 消