{"action":"created","issue":{"url":"https://api.github.com/repos/manuel-rabade/Alt9SoftSerial/issues/1","labels_url":"https://api.github.com/repos/manuel-rabade/Alt9SoftSerial/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/manuel-rabade/Alt9SoftSerial/issues/1/comments","events_url":"https://api.github.com/repos/manuel-rabade/Alt9SoftSerial/issues/1/events","html_url":"https://github.com/manuel-rabade/Alt9SoftSerial/issues/1","id":99115138,"number":1,"title":"not receiving most bits","user":{"login":"i-make-robots","id":1464454,"avatar_url":"https://avatars.githubusercontent.com/u/1464454?v=3","gravatar_id":"","url":"https://api.github.com/users/i-make-robots","html_url":"https://github.com/i-make-robots","followers_url":"https://api.github.com/users/i-make-robots/followers","following_url":"https://api.github.com/users/i-make-robots/following{/other_user}","gists_url":"https://api.github.com/users/i-make-robots/gists{/gist_id}","starred_url":"https://api.github.com/users/i-make-robots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/i-make-robots/subscriptions","organizations_url":"https://api.github.com/users/i-make-robots/orgs","repos_url":"https://api.github.com/users/i-make-robots/repos","events_url":"https://api.github.com/users/i-make-robots/events{/privacy}","received_events_url":"https://api.github.com/users/i-make-robots/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-08-05T04:40:29Z","updated_at":"2015-10-07T16:33:16Z","closed_at":null,"body":"Hi!  I've included Alt9SoftSerial in a project to talk to a vending machine.  The vending machine adheres to the MDB 4.2 spec, and uses a 9 bit protocol at 9600 baud.  I can access the machine through the Arduino UNO with hardware serial like so:\r\n\r\n```\r\n#define BAUD 9600\r\n#include <SoftwareSerial.h>\r\n#include <Wire.h> \r\n#include <util/setbaud.h>\r\n\r\nSoftwareSerial out(10,11);\r\n\r\nvoid setup() {\r\n  out.begin(57600);\r\n\r\n  // Set baud rate\r\n  UBRR0H = UBRRH_VALUE;\r\n  UBRR0L = UBRRL_VALUE;\r\n  // Disable USART rate doubler (arduino bootloader leaves it enabled...)\r\n  UCSR0A &= ~(1 << U2X0);\r\n\r\n  // Set asynchronous\r\n  UCSR0C = (0<<UMSEL01)|(0<<UMSEL00);\r\n  // set 1 stop bit\r\n  UCSR0C |= (0<<USBS0);\r\n  // set no parity\r\n  UCSR0C |= (0<<UPM01)|(0<<UPM00);\r\n  // set 9bit\r\n  UCSR0C |=(1<<UCSZ01)|(1<<UCSZ00);\r\n  UCSR0B |= (1<<UCSZ02);\r\n\r\n  UCSR0B |= (1<<RXEN0);  // Enable RX\r\n  UCSR0B |= (1<<TXEN0);  // Enable TX\r\n}\r\n\r\n// get data\r\nvoid loop() {\r\n  poll();\r\n}\r\n\r\nvoid poll();\r\n  // Wait for data to be received\r\n  while (!(UCSR0A & (1<<RXC0)));\r\n  // Get status and 9th bit, then data\r\n  // from buffer\r\n  unsigned char stat = UCSR0A;\r\n  unsigned char resh = UCSR0B;\r\n  unsigned char resl = UDR0;\r\n\r\n  // If error, return -1\r\n  if ( (stat & (1<<FE0)) | (stat & (1<<DOR0)) | (stat & (1<<UPE0))) {\r\n    //char tmpstr[64];\r\n    //sprintf(tmpstr, \"<RX ERR: %.2x [%d,%d,%d], [%.2x, %.2x]\", status, (status & (1<<FE0)), (status & (1<<DOR0)),(status & (1<<UPE0)), resh, resl);\r\n    //dbg_print(tmpstr);\r\n    return -1;\r\n  }\r\n\r\n  // Filter the 9th bit, then return\r\n  resh = (resh >> 1) & 0x01;\r\n  return (((unsigned int)resh << 8) | resl);\r\n}\r\n```\r\n\r\nWhen I run alt9softwareserial I almost never receive a value over 100, though the hardware version was reporting lots of data, and quite a bit has the 9th bit on.\r\n\r\nAny ideas?  I'd like to believe it's me, not you."},"comment":{"url":"https://api.github.com/repos/manuel-rabade/Alt9SoftSerial/issues/comments/146254505","html_url":"https://github.com/manuel-rabade/Alt9SoftSerial/issues/1#issuecomment-146254505","issue_url":"https://api.github.com/repos/manuel-rabade/Alt9SoftSerial/issues/1","id":146254505,"user":{"login":"i-make-robots","id":1464454,"avatar_url":"https://avatars.githubusercontent.com/u/1464454?v=3","gravatar_id":"","url":"https://api.github.com/users/i-make-robots","html_url":"https://github.com/i-make-robots","followers_url":"https://api.github.com/users/i-make-robots/followers","following_url":"https://api.github.com/users/i-make-robots/following{/other_user}","gists_url":"https://api.github.com/users/i-make-robots/gists{/gist_id}","starred_url":"https://api.github.com/users/i-make-robots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/i-make-robots/subscriptions","organizations_url":"https://api.github.com/users/i-make-robots/orgs","repos_url":"https://api.github.com/users/i-make-robots/repos","events_url":"https://api.github.com/users/i-make-robots/events{/privacy}","received_events_url":"https://api.github.com/users/i-make-robots/received_events","type":"User","site_admin":false},"created_at":"2015-10-07T16:33:16Z","updated_at":"2015-10-07T16:33:16Z","body":"Hello!  Sorry for the long delay.  Why are you writing pins 18 and 19 low?\nI can't see any evidence that either are used on a MEGA or an UNO.\n\nOn Fri, Aug 21, 2015 at 10:43 PM, Dan Royer <dan@marginallyclever.com>\nwrote:\n\n> I'm pretty sure... I'll check again.\n>\n>\n>\n> On Aug 21, 2015, at 3:40 PM, Manuel Rábade <notifications@github.com>\n> wrote:\n>\n> Sorry for the delay. I have tested your code (with a minor modification),\n> compiled against Arduino 1.5.6-r2 in a custom board with an ATmega328\n> connected to an MDB bus:\n>\n> #include\n> Alt9SoftSerial mdb;\n>\n> void setup() {\n> pinMode(18, OUTPUT);\n> pinMode(19, OUTPUT);\n> digitalWrite(18, LOW);\n> digitalWrite(19, LOW);\n>\n> Serial.begin(57600);\n> mdb.begin(9600);\n> }\n>\n> void loop() {\n> if(mdb.available()) {\n> Serial.println((int)mdb.read(),HEX);\n> }\n> }\n>\n> The output is:\n>\n> 1F0\n> 133\n> 33\n> 10B\n> B\n> 133\n> 33\n> 10B\n> B\n> 133\n> 33\n> 10B\n> B\n> 133\n> 33\n> ...\n> ...\n> ...\n>\n> As you can see I am receiving 9 bit values that make sense in a MDB bus.\n>\n> What branch are you using? You have to use the 9-bit branch (maybe the\n> README is not clear about this, sorry). If you are using master that is the\n> original AltSoftSerial to track upstream changes.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/manuel-rabade/Alt9SoftSerial/issues/1#issuecomment-133581161>\n> .\n>\n>\n\n\n-- \nDan Royer :: Marginally Clever <http://www.marginallyclevergroup.com/> ::\nRaising Robot Literacy :: +1.604.916.2281\n"}}