{"action":"created","issue":{"url":"https://api.github.com/repos/GBert/railroad/issues/2","labels_url":"https://api.github.com/repos/GBert/railroad/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/GBert/railroad/issues/2/comments","events_url":"https://api.github.com/repos/GBert/railroad/issues/2/events","html_url":"https://github.com/GBert/railroad/issues/2","id":62703367,"number":2,"title":"TCP-read  may cause erroneous message","user":{"login":"frehberg","id":4435830,"avatar_url":"https://avatars.githubusercontent.com/u/4435830?v=3","gravatar_id":"","url":"https://api.github.com/users/frehberg","html_url":"https://github.com/frehberg","followers_url":"https://api.github.com/users/frehberg/followers","following_url":"https://api.github.com/users/frehberg/following{/other_user}","gists_url":"https://api.github.com/users/frehberg/gists{/gist_id}","starred_url":"https://api.github.com/users/frehberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frehberg/subscriptions","organizations_url":"https://api.github.com/users/frehberg/orgs","repos_url":"https://api.github.com/users/frehberg/repos","events_url":"https://api.github.com/users/frehberg/events{/privacy}","received_events_url":"https://api.github.com/users/frehberg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-18T14:09:51Z","updated_at":"2015-12-02T11:13:19Z","closed_at":null,"body":"Hello,\r\n\r\nThe following line reads a bunch of bytes from TCP-connection.\r\n\r\n if ((n = read(tcp_socket, netframe, MAXDG)) == 0) {\r\n\r\nThe following code does not verify, if the read bytes represent a complete/single message, but forwards directly to CAN-socket.\r\n\r\nUsing TCP, it may happen, that the read-function returns with too little or too many bytes (for example only a fragment of the intended message or  also the first bytes of next message in stream)\r\n(Does not happen with message oriented UDP) \r\n\r\nIn this use-case, if the short messages are sent with high frequency via TCP, it is very likely that the TCP-reader in can2lan might read over the boundary of a single message, forwarding faulty messages to the Can-bus. \r\n\r\nTo solve the issue, the TCP-reader must verify that the read bytes match exactly one message. \r\nFor example the TCP-reader could read till the 5th byte udpframe[4] , defining the payload length N (DLC), and then continue reading the corresponding N bytes of the payload.\r\n\r\nCu, Frank"},"comment":{"url":"https://api.github.com/repos/GBert/railroad/issues/comments/161263855","html_url":"https://github.com/GBert/railroad/issues/2#issuecomment-161263855","issue_url":"https://api.github.com/repos/GBert/railroad/issues/2","id":161263855,"user":{"login":"GBert","id":3374327,"avatar_url":"https://avatars.githubusercontent.com/u/3374327?v=3","gravatar_id":"","url":"https://api.github.com/users/GBert","html_url":"https://github.com/GBert","followers_url":"https://api.github.com/users/GBert/followers","following_url":"https://api.github.com/users/GBert/following{/other_user}","gists_url":"https://api.github.com/users/GBert/gists{/gist_id}","starred_url":"https://api.github.com/users/GBert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GBert/subscriptions","organizations_url":"https://api.github.com/users/GBert/orgs","repos_url":"https://api.github.com/users/GBert/repos","events_url":"https://api.github.com/users/GBert/events{/privacy}","received_events_url":"https://api.github.com/users/GBert/received_events","type":"User","site_admin":false},"created_at":"2015-12-02T11:13:19Z","updated_at":"2015-12-02T11:13:19Z","body":"many thx for your suggestion. I will check it and look for a solution ..."}}