Skip to content

Instantly share code, notes, and snippets.

@geta6
Created December 17, 2013 07:16
Show Gist options
  • Select an option

  • Save geta6/8001233 to your computer and use it in GitHub Desktop.

Select an option

Save geta6/8001233 to your computer and use it in GitHub Desktop.
dgram = require 'dgram'
SIO_RIGHT = 2
SIO_LEFT = 1
ID_NECK = 0
ID_SHOULDER_ROTATION = 1
ID_SHOULDER_UP_DOWN = 2
ID_ELBOW = 4
ID_HIP_OPEN_CLOSE = 6
ID_HIP_BACK_FORTH = 7
ID_KNEE = 8
ID_ANKLE_UP_DOWN = 9
ID_ANKLE_OPEN_CLOSE = 10
POSITION_DEFAULT_MAX = 10000
POSITION_DEFAULT = 7500
POSITION_DEFAULT_MIN = 5000
makeIcs = (sio, id) ->
return (id * 2) + (sio - 1)
json = [
{ frame: 50 }
{
ics: makeIcs SIO_RIGHT, ID_NECK
value: 5000
}
{ command: 3 }
]
message = new Buffer JSON.stringify json
client = dgram.createSocket 'udp4'
client.send message, 0, message.length, 3500, '*.*.*.*', (err, bytes) ->
console.error err if err
console.log "send #{bytes} bytes"
console.log json
client.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment