将256个字节发送到串行端口后,要成功确认sendind,然后再发送下一个256个字节 [英] After Sending 256 bytes to serialport ,want ack sendind successfully then send next 256 bytes

查看:144
本文介绍了将256个字节发送到串行端口后,要成功确认sendind,然后再发送下一个256个字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉任何人,假设总大小为2560字节.我想每次发送256字节并获得发送成功"的确认.收到消息后,它将继续发送下一个256字节,直到2560字节成功发送.

Please tell anyone, suppose total size of is 2560 bytes.i want send each time 256 bytes and get acknowledgement "Send successfully".After getting messege it will send next 256 bytes till 2560 bytes send successfully.

推荐答案

然后,您需要做的比发送数据还要多-您要研究处理DataReceived事件(与计时器结合)并仅发送下一个块当您收到有效的回复时.这并不困难:只需设置一个输出流(例如)并发送一个块.设置计时器以显示响应失败的时间,以及当您获得串行端口响应时,确定它是否正常(因此发送另一个块),错误数据(因此重复该块)或取消(报告错误并使发送失败) )
我不能为您写它-我不知道什么连接到串行线的另一端以及它的响应.不过,这是非常基本的东西.
Then you need to look at doing a bit more than you sending the data - you want to look at handling the DataReceived event (in conjunction with a timer) and sending the next block only when you have a valid reply. It''s not difficult: just set up an output stream (for example) and send a block. Set the timer to show when the response failed, and when you get a serial port response, decide if it is an ok (so send another block), bad data (so repeat the block) or cancel (report an error and fail the send)
I can''t write it for you - I don''t know what is connected to the other end of the serial wire and what it responds with. It''s pretty basic stuff, though.


这篇关于将256个字节发送到串行端口后,要成功确认sendind,然后再发送下一个256个字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆