     port: port
   }
 
+# TODO: move all these down into "protocol", along with the inverse functions
 addNode = (payload, componentLib, buffer, index) ->
   nodeName = payload.id
   componentName = payload.component

  index += writeCmd buffer, index, cmdBuf
  return index

cmdStreamBuildGraph = (currentNodeId, buffer, index, componentLib, graph) ->
  messages = protocol.graphToFbpMessages graph, 'default'

  nodeMap = graph.nodeMap
  startIndex = index

  componentMap = {}
  for message in messages
    if message.command == 'addnode'
      name = message.payload.id

  r = if parent != undefined then graph.processes[nodeNameById(graph.nodeMap, parent)].graph.processes else graph.processes
  r[nodeName]

# TODO: move each parsing into individual function and merge logic deviceResponseToFbpProtocol
# to return a FBP runtime message directly. Should then be the inverse of toCommandStreamBuffer/addNode/addInitial etc.
parseReceivedCmd = (componentLib, graph, cmdData, handler) ->
  `var targetPort`
  `var targetNode`
