广州大彩串口屏论坛_大彩开发者交流论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 257|回复: 5

CAN通讯

[复制链接]

3

主题

8

帖子

47

积分

新手上路

Rank: 1

积分
47
发表于 2026-8-20 17:08:55 | 显示全部楼层 |阅读模式
在屏幕上录入12.3,怎么使用CAN通讯将数据发出来,屏幕收到750.1怎么显示在屏幕上?
回复

使用道具 举报

0

主题

1090

帖子

3246

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3246
发表于 2026-8-20 18:08:35 | 显示全部楼层
canbus_write(index,identifier,dlc,rtr,ide,data)
发送 CAN 报文

index:索引号 0~1
identifier:报文 ID
dlc:数据长度
rtr:远程帧
ide:扩展帧
data:数据, table 格式
1.9.4 on_canbus_recv(index,identifier,dlc,rtr,ide,data)
CAN 报文回调函数, 收到报文后, 系统自动调用

index:索引号 0~1
identifier:报文 ID
dlc:数据长度
rtr:远程帧
ide:扩展帧
data:数据, table 格式
回复

使用道具 举报

3

主题

8

帖子

47

积分

新手上路

Rank: 1

积分
47
 楼主| 发表于 2026-8-25 16:19:28 | 显示全部楼层
dctechnology 发表于 2026-8-20 18:08
canbus_write(index,identifier,dlc,rtr,ide,data)
发送 CAN 报文

你好,我想在问一下,在一个页面上,我需要设置很多数据,设置好后,需要点击发送数据按钮,这个是每个数据都要一个发送按钮吗?能共用一个吗?
function on_control_notify(screen,control,value)
        if screen== 0 and control==2 and value==1  
        then
        local input_text = get_value(0,3)*10
                send_data_buffer[0] =  input_text>> 8
                send_data_buffer[1] =  input_text&0xFF
                canbus_write(0,CAN_CMD_ID,2,0,0,send_data_buffer)

        end
end
回复

使用道具 举报

0

主题

1090

帖子

3246

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3246
发表于 2026-8-25 17:10:30 | 显示全部楼层
对应画面ID 控件ID操作
回复

使用道具 举报

3

主题

8

帖子

47

积分

新手上路

Rank: 1

积分
47
 楼主| 发表于 2026-8-26 10:50:45 | 显示全部楼层
dctechnology 发表于 2026-8-25 17:10
对应画面ID 控件ID操作

local send_data_buffer1 = {}
local send_data_buffer2 = {}
function on_control_notify(screen,control,value)
    if screen == 0 and control == 2 and value == 1 then
        -- 1. 读取并处理数据
        local input_text1 = get_value(0, 3) * 10
        local input_text2 = get_value(0, 6) * 10
        
        -- 2. 发送第1帧(ID = CAN_CMD_ID)
        send_data_buffer1[0] =  (input_text1 >> 8) & 0xFF
        send_data_buffer1[1] =  input_text1 & 0xFF  
        canbus_write(0, 0x0A, 2, 0, 0, send_data_buffer1)

        delay_ms(10)  -- 5毫秒
               
        -- 3. 发送第2帧(ID = 0x10)
        send_data_buffer2[0] =  (input_text2 >> 8) & 0xFF
        send_data_buffer2[1] =  input_text2 & 0xFF  
        canbus_write(0, 0x10, 2, 0, 0, send_data_buffer2)

    end
end
我这样写,第二帧不能发送数据,麻烦帮我看一下是怎么回事
回复

使用道具 举报

7

主题

38

帖子

863

积分

高级会员

Rank: 4

积分
863
发表于 2026-8-27 09:18:15 | 显示全部楼层
delay_ms()    确定有这个函数吗?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|广州大彩串口屏论坛_大彩开发者交流论坛

GMT+8, 2026-9-15 07:27 , Processed in 0.059359 second(s), 17 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表