3516开发板

编译环境配置

cat /etc/profile
arm-hisiv600-linux-gcc -v

busybox 精简的linux命令,比如busybox vi等

串口

串口(com接口)是指数据一位一位的顺序传送,通信简单,一对传输线就可以双向通信,传送数据慢。

串口出现的初期是为了实现连接计算机外设的目的,初期串口一般用来连接鼠标和外置Modem以及老式摄像头和写字板等设备。

comm串口

default

InitComm 初始化指定串口,创建串口

SetCommAttr 设置串口属性,CommSetAttr 设置串口属性

DestroyComm 销毁串口

ReadComm 读取数据

WriteComm 写入数据

FlushComm 清串口设备缓存

485串口ptz云台控制()

读取485串口数据

// @Title          读取485串口数据
// @Summary        读取485串口数据
// @Description    读取485串口数据
// @Success  200     {string}
// @Failure  400300  读取数据失败
// @router   /command [get]
func (c *Controller) Get485Data() {
	rsp := new(apis.Response)
	c.Data["json"] = rsp
	defer c.ServeJSON()

	data, ok := comm.ReadComm(comm.TypePtz, 32)
	if !ok {
		rsp.Error(errors.ErrGetCfgFailed)
		return
	}

	var output string
	for _, v := range data {
		output += fmt.Sprintf("%#.2x ", v)
	}

	rsp.Success(output)
}
  1. 传过来的数据先序列化为json
  2. 通过串口读取数据comm.ReadComm
  3. ok模式错误处理
  4. 遍历获取到的数据,成功返回

下发485串口指令

// @Title          下发485串口指令
// @Summary        下发485串口指令
// @Description    下发485串口指令,默认 0x01 0x02 0x03 0x04
// @Success  200
// @Failure  400000 操作失败
// @router   /command [put]
func (c *Controller) Set485Data() {
	rsp := new(apis.Response)
	c.Data["json"] = rsp
	defer c.ServeJSON()

	cmd := []byte{1, 2, 3, 4}
	if !comm.WriteComm(comm.TypePtz, cmd) {
		rsp.Error(errors.ErrOprFailed)
		return
	}

	rsp.Success()
}
  1. 返回json数据
  2. byte切片1,2,3,4
  3. 切片串口写入comm.WriteComm
  4. 错误处理,成功返回
2021/08/05 08:33:20.557 [I] [service.go:25]  act user info: &{1 admin admin Administrator 2021-07-29 08:48:52}
2021/08/05 08:33:20.557 [W] [service.go:38]  agtb.Authority: {true true true true true true true true true true true [true true] [true true]} model.AuthorityList
2021/08/05 08:33:20.559 [I] [configmgr.go:194]  exec config[TempLines] callback function[neuron/function/thermal/thermaltemp/blp.(*TempManager).OnApplyConfigTempLine-fm].

云台上下左右转动指令,运转停止指令,预设点操作指令

改变云台光圈大小,聚焦远近,焦距长短或停止所有动作

http

// @Title          云台改变或停止
// @Summary        云台改变或停止
// @Description    改变云台光圈大小,焦距长短,聚焦远近或停止
// @Param	 method  query   string    true	   "方法名分别为focalShorter,focalLonger,focusCloser,focusFarther,apertureSmaller,apertureLarger,stop"
// @Success  200
// @Failure  400000        操作失败
// @router   /changeOrStop [put]
func (c *Controller) ChangeOrStop() {
    //返回
	var rsp = new(apis.Response)
	defer func() {
		c.Data["json"] = rsp
		c.ServeJSON()
	}()

	method := c.GetString("method")
	if !blp.GetIns().ChangeOrStop(method) {
		rsp.Error(errors.ErrOprFailed)
		return
	}

	rsp.Success()
}
// ChangeOrStop 改变云台光圈大小,聚焦远近,焦距长短或停止所有动作
func (c *PtzClient) ChangeOrStop(method string) bool {
	inputParam := InputParam{}
	if cmd, ok := dsd.PelcoMap[method]; ok {
		inputParam.Cmd = cmd
		inputParam.Data = DataSt{0x00, 0x00}
	}

	return c.SendCmd(&inputParam)
}

image-20210806104335006

image-20210806104428834

波特率:每秒钟传送的码元符号的个数,是衡量数据传送速率的指标。

1、波特率9600:每秒可以传输9200/8个英文字母。

2、波特率19200:每秒可传输19200/8个英文字母。

模组又称模块是指由数个基础功能组件组成的特定功能组件,可用来组成具完整功能之系统、设备或程序。模块通常都会具有相同的制程或逻辑,更改其组成组件可调适其功能或用途

posted @ 2022-01-22 14:39  凌易说-lingyisay  阅读(100)  评论(0编辑  收藏  举报