9

Senior argue with me that Java can’t do serial programming, I prove to him by read the hardware protocol in HEX , and convert to ASCII using Java. He said the F word to me , I was like “他是什麼意思啊?”

Comments
  • 5
    If you can develop, develop than. If you can't, put the senior word before your degree and command others who actualy can.
  • 6
    arduino ide is in java
  • 8
    Sounds like the Peter principle is working well at your company

    https://en.m.wikipedia.org/wiki/...
  • 0
    Could you show some code where you're reading raw bytes from hardware device? I'm quite curious as every solution I'm aware of uses third-party libraries in C / C++ / ... to support that.
  • 0
    @hitko https://sourceforge.net/p/...

    If you dont wanna read the code, its just gnu.io._ and a stream/bufferedreader
  • 0
    @tekashi That uses jSerialComm, which is written in C and compiled for each platform. It just has Java bindings, and that's exactly the "can't do it in Java" I believe @johnmelodyme's senior meant.
  • 0
    @hitko if you really want to, you can just read the file unix dumps serial data into
  • 2
    @tekashi Yeah, that would work to display HEX data from a device and possibly send some bits to it. Problem is it's by design practically impossible to do anything more with it without system calls, and unless a language provides bindings for those calls (which Java & other higher-level languages don't, except for a handful of basic operations), then you need a native library.

    Can you interact with serial devices in Java? Yes. Can you do it in pure Java, so it can be platform-agnostic? No, since it's not a part of Java runtime, but you can achieve the most basic access on a limited number of systems.
Add Comment