Exemplo n.º 1
0
func generator(t time.Duration) {
	for {
		var s conn.Setting
		s.GetSetting()
		if s.Isconnected {
			var k ftprotocol.KeepAlive
			k.SessionKey = []byte(s.Sessionkey)
			k.Sequence = byte(s.Sequence[0])

			//			log.Printf("session key : %X, sequence : %X\n", k.SessionKey, k.Sequence)

			//		log.Printf("send keepalive : %X", k.Message())

			var m conn.Message
			m.Messagetype = conn.REQUEST
			m.Info = hex.EncodeToString(k.Message())
			m.Status = conn.NONE

			m.InsertMessage()

			//			sequence = IncreaseSeq(sequence)

		}

		time.Sleep(time.Millisecond * time.Duration(t))
		//		time.Sleep(time.Millisecond * time.Duration(s.Writeinterval))

	}

}
Exemplo n.º 2
0
func (c *SerialController) SendMessage() {
	input := c.GetString("input")

	var m conn.Message
	m.Messagetype = conn.REQUEST
	m.Info = input
	m.Status = conn.NONE
	m.InsertMessage()

	c.Ctx.WriteString("ok")
}
Exemplo n.º 3
0
func reader(t time.Duration) {
	for {
		var m conn.Message
		b, _ := comm.Reader()
		if len(b) > 0 {
			m.Messagetype = conn.RESPONSE
			m.Info = hex.EncodeToString(b)
			m.Status = conn.NONE
			log.Printf("Received : %X", b)
			m.InsertMessage()

		}
		time.Sleep(time.Millisecond * t)

	}

}
Exemplo n.º 4
0
func (c *MesssageController) SendPwdKey() {

	messageid := ftprotocol.SCREENPRESS
	var setting conn.Setting
	setting.GetSetting()

	switch messageid {
	case ftprotocol.SCREENPRESS:
		var g ftprotocol.ScreenPress

		g.SessionKey = []byte(strings.ToUpper(setting.Sessionkey))
		g.MessageID = []byte(strings.ToUpper(c.GetString("messageid")))
		g.Sequence = byte(setting.Sequence[0])

		screenid, _ := c.GetInt32("screenid")
		g.ScreenID = uint32(screenid)

		coorx, _ := c.GetInt32("coorx")
		g.X = uint32(coorx)

		coory, _ := c.GetInt32("coory")
		g.Y = uint32(coory)

		//		log.Println(g)

		out := g.Message()

		//		log.Println(out)

		var m conn.Message
		m.Messagetype = conn.REQUEST
		m.Info = hex.EncodeToString(out)
		m.Status = conn.NONE
		log.Println(m.Info)

		m.InsertMessage()

		c.Ctx.WriteString("ok")

	default:
		c.Ctx.WriteString("Invalid Message")

	}

}