{"action":"created","comment":{"url":"https://api.github.com/repos/Team846/potassium/pulls/comments/97471401","pull_request_review_id":18080027,"id":97471401,"diff_hunk":"@@ -0,0 +1,158 @@\n+package com.lynbrookrobotics.potassium.lighting\n+\n+import java.io.{InputStream, OutputStream}\n+\n+import gnu.io.{CommPortIdentifier, SerialPort}\n+\n+import scala.collection.mutable\n+\n+/**\n+  * Created by Timothy on 1/14/2017.\n+  * Communication protocol for communicating with serial devices.\n+  */\n+class TwoWayComm{\n+\n+  /**\n+    * DO NOT USE\n+    */\n+  val dataQueue = mutable.Queue[Int]()\n+  /**\n+    * DO NOT USE\n+    */\n+  val logQueue = mutable.Queue[String]()\n+\n+  /**\n+    * Connect to serial device\n+    *\n+    */\n+  def connect(): Unit = {\n+    val portName = systemPort()\n+    val portIdentifier = CommPortIdentifier getPortIdentifier portName\n+    if (portIdentifier.isCurrentlyOwned) {\n+      logQueue.enqueue(\"Error: Port currently in use\")\n+    }\n+    else {\n+      val commPort = portIdentifier open(this getClass() getName(), 2000)\n+      commPort match {\n+        case serialPort: SerialPort =>\n+          serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE)\n+\n+          val in = serialPort.getInputStream\n+          val out = serialPort.getOutputStream\n+\n+          new Thread(new SerialReader(in)).start()\n+          new Thread(new SerialWriter(out)).start()\n+        case default => logQueue.enqueue(\"something went wrong...\")\n+      }\n+    }\n+  }\n+\n+  class SerialReader(val in: InputStream) extends Runnable {\n+    override def run(): Unit = {\n+      val bucket = new Array[Byte](1024)\n+      try {\n+        var len = -1;\n+        while ({\n+          len = this.in.read(bucket)\n+          len > -1\n+        }) {\n+          val tmp = new String(bucket, 0, len)\n+          if(tmp != \"\") {\n+            logQueue.enqueue(tmp)\n+          }\n+        }\n+      } catch {\n+        case e: Exception => e.printStackTrace()\n+      }\n+    }\n+  }\n+\n+  class SerialWriter(val out: OutputStream) extends Runnable {\n+    override def run(): Unit = {\n+      try {\n+        var c = 0\n+        while ( {\n+          if(dataQueue.nonEmpty) {\n+            c = dataQueue.dequeue()\n+          }else{\n+            c = 0\n+          }\n+          c > -1\n+        }) {\n+          this.out.write(c)\n+        }\n+      } catch {\n+        case e: Exception => e.printStackTrace()\n+      }\n+    }\n+  }\n+\n+  /**\n+    * Pushes a number to the data queue to be processed\n+    *\n+    * @param data integer to be sent\n+    */\n+  def pushDataToQueue(data: String): Unit = {\n+    for(c <- data){\n+      dataQueue.enqueue(c.toInt)","path":"lighting/src/main/scala/com/lynbrookrobotics/potassium/lighting/TwoWayComm.scala","position":97,"original_position":97,"commit_id":"0734053ed92e25819672e314173884e7a9977970","original_commit_id":"0734053ed92e25819672e314173884e7a9977970","user":{"login":"Paxelord","id":11010625,"avatar_url":"https://avatars.githubusercontent.com/u/11010625?v=3","gravatar_id":"","url":"https://api.github.com/users/Paxelord","html_url":"https://github.com/Paxelord","followers_url":"https://api.github.com/users/Paxelord/followers","following_url":"https://api.github.com/users/Paxelord/following{/other_user}","gists_url":"https://api.github.com/users/Paxelord/gists{/gist_id}","starred_url":"https://api.github.com/users/Paxelord/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Paxelord/subscriptions","organizations_url":"https://api.github.com/users/Paxelord/orgs","repos_url":"https://api.github.com/users/Paxelord/repos","events_url":"https://api.github.com/users/Paxelord/events{/privacy}","received_events_url":"https://api.github.com/users/Paxelord/received_events","type":"User","site_admin":false},"body":"Try dataQueue.foreach","created_at":"2017-01-24T04:10:37Z","updated_at":"2017-01-24T04:23:23Z","html_url":"https://github.com/Team846/potassium/pull/8#discussion_r97471401","pull_request_url":"https://api.github.com/repos/Team846/potassium/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/Team846/potassium/pulls/comments/97471401"},"html":{"href":"https://github.com/Team846/potassium/pull/8#discussion_r97471401"},"pull_request":{"href":"https://api.github.com/repos/Team846/potassium/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/Team846/potassium/pulls/8","id":101994927,"html_url":"https://github.com/Team846/potassium/pull/8","diff_url":"https://github.com/Team846/potassium/pull/8.diff","patch_url":"https://github.com/Team846/potassium/pull/8.patch","issue_url":"https://api.github.com/repos/Team846/potassium/issues/8","number":8,"state":"open","locked":false,"title":"Created a method of lighting control","user":{"login":"wafflemans","id":10857677,"avatar_url":"https://avatars.githubusercontent.com/u/10857677?v=3","gravatar_id":"","url":"https://api.github.com/users/wafflemans","html_url":"https://github.com/wafflemans","followers_url":"https://api.github.com/users/wafflemans/followers","following_url":"https://api.github.com/users/wafflemans/following{/other_user}","gists_url":"https://api.github.com/users/wafflemans/gists{/gist_id}","starred_url":"https://api.github.com/users/wafflemans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wafflemans/subscriptions","organizations_url":"https://api.github.com/users/wafflemans/orgs","repos_url":"https://api.github.com/users/wafflemans/repos","events_url":"https://api.github.com/users/wafflemans/events{/privacy}","received_events_url":"https://api.github.com/users/wafflemans/received_events","type":"User","site_admin":false},"body":"Added TwoWayComm as a method of communicating with serial devices\r\nAdded unit tests\r\nAdded DisplayLighting as a continuous task to change LED color","created_at":"2017-01-18T03:49:18Z","updated_at":"2017-01-24T04:23:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8a9220fa5d8413e2a13a2a841278efea6a687864","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Team846/potassium/pulls/8/commits","review_comments_url":"https://api.github.com/repos/Team846/potassium/pulls/8/comments","review_comment_url":"https://api.github.com/repos/Team846/potassium/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Team846/potassium/issues/8/comments","statuses_url":"https://api.github.com/repos/Team846/potassium/statuses/0734053ed92e25819672e314173884e7a9977970","head":{"label":"Team846:lighting","ref":"lighting","sha":"0734053ed92e25819672e314173884e7a9977970","user":{"login":"Team846","id":12131787,"avatar_url":"https://avatars.githubusercontent.com/u/12131787?v=3","gravatar_id":"","url":"https://api.github.com/users/Team846","html_url":"https://github.com/Team846","followers_url":"https://api.github.com/users/Team846/followers","following_url":"https://api.github.com/users/Team846/following{/other_user}","gists_url":"https://api.github.com/users/Team846/gists{/gist_id}","starred_url":"https://api.github.com/users/Team846/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Team846/subscriptions","organizations_url":"https://api.github.com/users/Team846/orgs","repos_url":"https://api.github.com/users/Team846/repos","events_url":"https://api.github.com/users/Team846/events{/privacy}","received_events_url":"https://api.github.com/users/Team846/received_events","type":"Organization","site_admin":false},"repo":{"id":69409393,"name":"potassium","full_name":"Team846/potassium","owner":{"login":"Team846","id":12131787,"avatar_url":"https://avatars.githubusercontent.com/u/12131787?v=3","gravatar_id":"","url":"https://api.github.com/users/Team846","html_url":"https://github.com/Team846","followers_url":"https://api.github.com/users/Team846/followers","following_url":"https://api.github.com/users/Team846/following{/other_user}","gists_url":"https://api.github.com/users/Team846/gists{/gist_id}","starred_url":"https://api.github.com/users/Team846/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Team846/subscriptions","organizations_url":"https://api.github.com/users/Team846/orgs","repos_url":"https://api.github.com/users/Team846/repos","events_url":"https://api.github.com/users/Team846/events{/privacy}","received_events_url":"https://api.github.com/users/Team846/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Team846/potassium","description":"A framework for writing robot software with functional programming in Scala","fork":false,"url":"https://api.github.com/repos/Team846/potassium","forks_url":"https://api.github.com/repos/Team846/potassium/forks","keys_url":"https://api.github.com/repos/Team846/potassium/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Team846/potassium/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Team846/potassium/teams","hooks_url":"https://api.github.com/repos/Team846/potassium/hooks","issue_events_url":"https://api.github.com/repos/Team846/potassium/issues/events{/number}","events_url":"https://api.github.com/repos/Team846/potassium/events","assignees_url":"https://api.github.com/repos/Team846/potassium/assignees{/user}","branches_url":"https://api.github.com/repos/Team846/potassium/branches{/branch}","tags_url":"https://api.github.com/repos/Team846/potassium/tags","blobs_url":"https://api.github.com/repos/Team846/potassium/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Team846/potassium/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Team846/potassium/git/refs{/sha}","trees_url":"https://api.github.com/repos/Team846/potassium/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Team846/potassium/statuses/{sha}","languages_url":"https://api.github.com/repos/Team846/potassium/languages","stargazers_url":"https://api.github.com/repos/Team846/potassium/stargazers","contributors_url":"https://api.github.com/repos/Team846/potassium/contributors","subscribers_url":"https://api.github.com/repos/Team846/potassium/subscribers","subscription_url":"https://api.github.com/repos/Team846/potassium/subscription","commits_url":"https://api.github.com/repos/Team846/potassium/commits{/sha}","git_commits_url":"https://api.github.com/repos/Team846/potassium/git/commits{/sha}","comments_url":"https://api.github.com/repos/Team846/potassium/comments{/number}","issue_comment_url":"https://api.github.com/repos/Team846/potassium/issues/comments{/number}","contents_url":"https://api.github.com/repos/Team846/potassium/contents/{+path}","compare_url":"https://api.github.com/repos/Team846/potassium/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Team846/potassium/merges","archive_url":"https://api.github.com/repos/Team846/potassium/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Team846/potassium/downloads","issues_url":"https://api.github.com/repos/Team846/potassium/issues{/number}","pulls_url":"https://api.github.com/repos/Team846/potassium/pulls{/number}","milestones_url":"https://api.github.com/repos/Team846/potassium/milestones{/number}","notifications_url":"https://api.github.com/repos/Team846/potassium/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Team846/potassium/labels{/name}","releases_url":"https://api.github.com/repos/Team846/potassium/releases{/id}","deployments_url":"https://api.github.com/repos/Team846/potassium/deployments","created_at":"2016-09-28T00:18:31Z","updated_at":"2016-10-26T17:37:14Z","pushed_at":"2017-01-24T03:36:02Z","git_url":"git://github.com/Team846/potassium.git","ssh_url":"git@github.com:Team846/potassium.git","clone_url":"https://github.com/Team846/potassium.git","svn_url":"https://github.com/Team846/potassium","homepage":"","size":143,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"Team846:master","ref":"master","sha":"13e885d99d4e86753517f9e8f1eefa6390ae5a4e","user":{"login":"Team846","id":12131787,"avatar_url":"https://avatars.githubusercontent.com/u/12131787?v=3","gravatar_id":"","url":"https://api.github.com/users/Team846","html_url":"https://github.com/Team846","followers_url":"https://api.github.com/users/Team846/followers","following_url":"https://api.github.com/users/Team846/following{/other_user}","gists_url":"https://api.github.com/users/Team846/gists{/gist_id}","starred_url":"https://api.github.com/users/Team846/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Team846/subscriptions","organizations_url":"https://api.github.com/users/Team846/orgs","repos_url":"https://api.github.com/users/Team846/repos","events_url":"https://api.github.com/users/Team846/events{/privacy}","received_events_url":"https://api.github.com/users/Team846/received_events","type":"Organization","site_admin":false},"repo":{"id":69409393,"name":"potassium","full_name":"Team846/potassium","owner":{"login":"Team846","id":12131787,"avatar_url":"https://avatars.githubusercontent.com/u/12131787?v=3","gravatar_id":"","url":"https://api.github.com/users/Team846","html_url":"https://github.com/Team846","followers_url":"https://api.github.com/users/Team846/followers","following_url":"https://api.github.com/users/Team846/following{/other_user}","gists_url":"https://api.github.com/users/Team846/gists{/gist_id}","starred_url":"https://api.github.com/users/Team846/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Team846/subscriptions","organizations_url":"https://api.github.com/users/Team846/orgs","repos_url":"https://api.github.com/users/Team846/repos","events_url":"https://api.github.com/users/Team846/events{/privacy}","received_events_url":"https://api.github.com/users/Team846/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Team846/potassium","description":"A framework for writing robot software with functional programming in Scala","fork":false,"url":"https://api.github.com/repos/Team846/potassium","forks_url":"https://api.github.com/repos/Team846/potassium/forks","keys_url":"https://api.github.com/repos/Team846/potassium/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Team846/potassium/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Team846/potassium/teams","hooks_url":"https://api.github.com/repos/Team846/potassium/hooks","issue_events_url":"https://api.github.com/repos/Team846/potassium/issues/events{/number}","events_url":"https://api.github.com/repos/Team846/potassium/events","assignees_url":"https://api.github.com/repos/Team846/potassium/assignees{/user}","branches_url":"https://api.github.com/repos/Team846/potassium/branches{/branch}","tags_url":"https://api.github.com/repos/Team846/potassium/tags","blobs_url":"https://api.github.com/repos/Team846/potassium/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Team846/potassium/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Team846/potassium/git/refs{/sha}","trees_url":"https://api.github.com/repos/Team846/potassium/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Team846/potassium/statuses/{sha}","languages_url":"https://api.github.com/repos/Team846/potassium/languages","stargazers_url":"https://api.github.com/repos/Team846/potassium/stargazers","contributors_url":"https://api.github.com/repos/Team846/potassium/contributors","subscribers_url":"https://api.github.com/repos/Team846/potassium/subscribers","subscription_url":"https://api.github.com/repos/Team846/potassium/subscription","commits_url":"https://api.github.com/repos/Team846/potassium/commits{/sha}","git_commits_url":"https://api.github.com/repos/Team846/potassium/git/commits{/sha}","comments_url":"https://api.github.com/repos/Team846/potassium/comments{/number}","issue_comment_url":"https://api.github.com/repos/Team846/potassium/issues/comments{/number}","contents_url":"https://api.github.com/repos/Team846/potassium/contents/{+path}","compare_url":"https://api.github.com/repos/Team846/potassium/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Team846/potassium/merges","archive_url":"https://api.github.com/repos/Team846/potassium/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Team846/potassium/downloads","issues_url":"https://api.github.com/repos/Team846/potassium/issues{/number}","pulls_url":"https://api.github.com/repos/Team846/potassium/pulls{/number}","milestones_url":"https://api.github.com/repos/Team846/potassium/milestones{/number}","notifications_url":"https://api.github.com/repos/Team846/potassium/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Team846/potassium/labels{/name}","releases_url":"https://api.github.com/repos/Team846/potassium/releases{/id}","deployments_url":"https://api.github.com/repos/Team846/potassium/deployments","created_at":"2016-09-28T00:18:31Z","updated_at":"2016-10-26T17:37:14Z","pushed_at":"2017-01-24T03:36:02Z","git_url":"git://github.com/Team846/potassium.git","ssh_url":"git@github.com:Team846/potassium.git","clone_url":"https://github.com/Team846/potassium.git","svn_url":"https://github.com/Team846/potassium","homepage":"","size":143,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Team846/potassium/pulls/8"},"html":{"href":"https://github.com/Team846/potassium/pull/8"},"issue":{"href":"https://api.github.com/repos/Team846/potassium/issues/8"},"comments":{"href":"https://api.github.com/repos/Team846/potassium/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/Team846/potassium/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/Team846/potassium/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Team846/potassium/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/Team846/potassium/statuses/0734053ed92e25819672e314173884e7a9977970"}}}}
{"actor":{"display_login":"Paxelord"}}