规范串口通讯

This commit is contained in:
2024-12-19 10:49:02 +08:00
parent 3f760e2955
commit b4913d63b3
5 changed files with 37 additions and 21 deletions

View File

@@ -48,7 +48,7 @@ func PushCard(ctx context.Context) leaf.HandlerFunc {
devices := make([]*card_pusher.Device, 0)
for i, group := range g.PushGroups {
// 对读卡器初始化配置
reader.SetSlave(uint8(i + 1))
reader.SetSlave(byte(i + 1))
err = reader.Init()
if err != nil {
zap.S().Panicln("读卡器初始配置失败", err)
@@ -114,7 +114,7 @@ func PushCard(ctx context.Context) leaf.HandlerFunc {
if body.num != 0 {
// 若卡片就位,读取卡片信息
if devices[body.num-1].GetOutOk() == 1 {
reader.SetSlave(uint8(body.num))
reader.SetSlave(byte(body.num))
if info := reader.GetCardInfo(); info != nil {
body.CardId = info.ID
}