{"action":"created","issue":{"url":"https://api.github.com/repos/Pi4J/pi4j/issues/135","labels_url":"https://api.github.com/repos/Pi4J/pi4j/issues/135/labels{/name}","comments_url":"https://api.github.com/repos/Pi4J/pi4j/issues/135/comments","events_url":"https://api.github.com/repos/Pi4J/pi4j/issues/135/events","html_url":"https://github.com/Pi4J/pi4j/issues/135","id":58472087,"number":135,"title":"Serial Communication byte errors","user":{"login":"tj128","id":11138639,"avatar_url":"https://avatars.githubusercontent.com/u/11138639?v=3","gravatar_id":"","url":"https://api.github.com/users/tj128","html_url":"https://github.com/tj128","followers_url":"https://api.github.com/users/tj128/followers","following_url":"https://api.github.com/users/tj128/following{/other_user}","gists_url":"https://api.github.com/users/tj128/gists{/gist_id}","starred_url":"https://api.github.com/users/tj128/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tj128/subscriptions","organizations_url":"https://api.github.com/users/tj128/orgs","repos_url":"https://api.github.com/users/tj128/repos","events_url":"https://api.github.com/users/tj128/events{/privacy}","received_events_url":"https://api.github.com/users/tj128/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-21T19:44:48Z","updated_at":"2015-02-22T22:51:26Z","closed_at":null,"body":"Hi there, Great work on the library, it works great and is easy to use, however I am stuck on one problem which I believe is within the library but please correct me if I'm wrong... \r\n\r\nI am using a raspberry pi with the pi4j Serial communication library to try and communicate with a separate pc. I am sending and receiving data in both directions, but when looking at the data in hex representation there are constant errors that occur.\r\n\r\nWhen reading data from the serial port using the 'event.getdata()' again many examples work fine, but if an 8 is present or a letter starts the string some bytes are missing and other added. e.g. sending 'e4 04 82 00 04 92' comes out on the pi screen as 'c3 a4 04 c2 82 00 04 c2 92'. most of the data is there but is split up and random characters added!\r\n \r\nI am using the Hex.encodeHexString from apache to convert from string to hex, which as far as i can tell through other testing does not have a problem with it...\r\n\r\nAny suggestions on how to get around this problem?    I just want to view hex coming in from the serial port!\r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/Pi4J/pi4j/issues/comments/75468697","html_url":"https://github.com/Pi4J/pi4j/issues/135#issuecomment-75468697","issue_url":"https://api.github.com/repos/Pi4J/pi4j/issues/135","id":75468697,"user":{"login":"savageautomate","id":2251458,"avatar_url":"https://avatars.githubusercontent.com/u/2251458?v=3","gravatar_id":"","url":"https://api.github.com/users/savageautomate","html_url":"https://github.com/savageautomate","followers_url":"https://api.github.com/users/savageautomate/followers","following_url":"https://api.github.com/users/savageautomate/following{/other_user}","gists_url":"https://api.github.com/users/savageautomate/gists{/gist_id}","starred_url":"https://api.github.com/users/savageautomate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/savageautomate/subscriptions","organizations_url":"https://api.github.com/users/savageautomate/orgs","repos_url":"https://api.github.com/users/savageautomate/repos","events_url":"https://api.github.com/users/savageautomate/events{/privacy}","received_events_url":"https://api.github.com/users/savageautomate/received_events","type":"User","site_admin":false},"created_at":"2015-02-22T22:51:26Z","updated_at":"2015-02-22T22:51:26Z","body":"Hi tj128,\r\n\r\nI have been working on a new serial implementation to properly support a byte level interface for working with the data.  I suggest that you try the experimental build 1.1-SNAPSHOT.  The serial API is completely overhauled and should provide far better results when working with bytes. \r\n\r\nGITHUB BRANCH:\r\nhttps://github.com/Pi4J/pi4j/tree/serial_enhancements\r\n\r\nDOWNLOAD:\r\nhttp://get.pi4j.com/download/pi4j-1.1-SNAPSHOT.zip\r\n\r\nPlease let me know if you find any problems ... remember it is very new and experimental :-)\r\n\r\nSample code below:\r\n\r\n```\r\nimport com.pi4j.io.serial.Baud;\r\nimport com.pi4j.io.serial.DataBits;\r\nimport com.pi4j.io.serial.FlowControl;\r\nimport com.pi4j.io.serial.Parity;\r\nimport com.pi4j.io.serial.Serial;\r\nimport com.pi4j.io.serial.SerialDataEvent;\r\nimport com.pi4j.io.serial.SerialDataEventListener;\r\nimport com.pi4j.io.serial.SerialFactory;\r\nimport com.pi4j.io.serial.StopBits;\r\nimport java.io.IOException;\r\nimport java.util.Date;\r\n\r\npublic class SerialExample1 {\r\n    \r\n    /**\r\n     * @param args the command line arguments\r\n     * @throws java.lang.InterruptedException\r\n     * @throws java.io.IOException\r\n     */\r\n    public static void main(String[] args) throws InterruptedException, IOException {\r\n \r\n        // !! ATTENTION !!\r\n        // By default, the on-board serial port is configured as a console port \r\n        // for interacting with the Linux OS shell.  If you want to use \r\n        // the serial port in a software program, you must disable the \r\n        // OS from using this port.  Or you can use a USB to serial adapter.\r\n                \r\n        System.out.println(\"<--Pi4J--> Serial Communication Example ... started.\");\r\n        System.out.println(\" ... connect using settings: 38400, N, 8, 1.\");\r\n        System.out.println(\" ... data received on serial port should be displayed below.\");\r\n\r\n        // create an instance of the serial communications class\r\n        final Serial serial = SerialFactory.createInstance();\r\n\r\n        // create and register the serial data listener\r\n        serial.addListener((SerialDataEventListener) (SerialDataEvent event) -> {\r\n            try {\r\n                System.out.println(\"[BYTES RECEIVED (\" + event.length() + \")]  \" +\r\n                        event.getHexByteString());\r\n            } catch (IOException ex) {\r\n                System.err.println(ex.getMessage());\r\n            }\r\n        });\r\n        \r\n        try {\r\n            // open the default serial port provided on the GPIO header\r\n            serial.open(Serial.FIRST_USB_COM_PORT, Baud._38400, DataBits._8, \r\n                        Parity.NONE, StopBits._1, FlowControl.HARDWARE);\r\n\r\n            // if your program is not going to read the received data from\r\n            // the serial receive buffer, then disable buffering!\r\n            //serial.setBufferingDataReceived(false);\r\n\r\n            // continuous loop to keep the program running until the user terminates\r\n            for (;;) {\r\n                // write a formatted string to the serial transmit buffer\r\n                serial.writeln(\"CURRENT TIME: \" + new Date().toString());\r\n                \r\n                // wait 1 second before continuing\r\n                Thread.sleep(1000);\r\n            }\r\n        }\r\n        catch(IllegalStateException|IOException ex) {\r\n            System.err.println(ex.getMessage());\r\n        }\r\n    }\r\n}\r\n```\r\n"}}