This repository has been archived by the owner on Dec 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/development' into development
- Loading branch information
Showing
7 changed files
with
64 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.sert2521.powerup.util | ||
|
||
import com.google.gson.Gson | ||
import java.net.DatagramPacket | ||
import java.net.DatagramSocket | ||
|
||
object UDPServer : Thread() { | ||
private val PACKET_SIZE = 256 | ||
|
||
private val socket = DatagramSocket(UDP_PORT) | ||
private val gson = Gson() | ||
|
||
override fun run() { | ||
val buf = ByteArray(PACKET_SIZE) | ||
val packet = DatagramPacket(buf, buf.size) | ||
|
||
socket.receive(packet) | ||
val msg = String(packet.data).trim { it <= ' ' } | ||
|
||
if (!msg.contains("alive")) { | ||
gson.fromJson(msg, VisionData.javaClass).also { | ||
VisionData.apply { | ||
foundCube = it.foundCube | ||
time = it.time | ||
xOffset = it.xOffset | ||
yOffset = it.yOffset | ||
} | ||
} | ||
|
||
println("Message from ${packet.address.hostAddress}: $msg") | ||
} else { | ||
println("Heartbeat from ${packet.address.hostAddress}") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.sert2521.powerup.util | ||
|
||
object VisionData { | ||
var foundCube = false | ||
var time = 0 | ||
var xOffset: Int? = null | ||
var yOffset: Int? = null | ||
} |
1664506
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, whoever made this commit – gotta make sure we don't make merge commits on dev/master, please! A lot of work to remove them!
1664506
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this contains a lot of non-working code. Probably merged by accident but just gotta make sure it's double-checked before pushing.