'Plugin currently assumes ascii strings

Function serial_Initialize(msgPort As Object, userVariables As Object, bsp as Object)

    print "seriale_Initialize - entry"

    serial = newserial(msgPort, userVariables, bsp)

    return serial

End Function


Function newserial(msgPort As Object, userVariables As Object, bsp as Object)
	print "newserial"

	s = {}
	s.version = 0.1
	s.msgPort = msgPort
	s.userVariables = userVariables
	s.bsp = bsp
	s.ProcessEvent = serial_ProcessEvent
	s.objectName = "serial_object"
	s.debug  = false
	return s
End Function


Function serial_ProcessEvent(event As Object) as boolean
	print "processing event serial plugin"
	retval = false

	if type(event) = "roTimerEvent" then

	else if type(event) = "roStreamLineEvent" then
		'carriage return terminated serial string

		command$= ""
		command$ = event.getstring()

		'send zone message with serial command value
		sendZoneMessageParameter$ = command$
		zoneMessageCmd = CreateObject("roAssociativeArray")
		zoneMessageCmd["EventType"] = "SEND_ZONE_MESSAGE"
		zoneMessageCmd["EventParameter"] = sendZoneMessageParameter$
		m.msgPort.PostMessage(zoneMessageCmd)

	end if

	return retval

End Function



