带串行PIC单片机的C#表格 [英] C# Form with Serial PIC Microcontroller

查看:62
本文介绍了带串行PIC单片机的C#表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,它使用通过RS232(PIC eze中的UART)连接到PC的PIC24单片机。表单向控制器发送命令,然后重新发送数据然后发回数据。其中一个命令是一种倒计时器。控制器将
从9减少到0.我要做的是让控制器向C#表单发送退格命令,然后显示下一个数字,这样就不需要清除并重新打印所有内容。问题是我似乎无法找到正确的值来
发送到C#表单以获得实际的退格。我试过发送\b和0x08,但是我得到的是一个空格或奇怪的菱形字符。


有没有人知道如何通过RS232发送退格字符?

解决方案

你好mityeltu,


也许你需要在 之间定义一个匹配的格式?编码和解码。在C#中可以这样做。在发送之前,你可以获得字节,并在接收时将其转换为字符。

 var bytes = Encoding.ASCII.GetBytes(" \b \b"); 

var chars = Encoding.ASCII.GetString(bytes);

还可以尝试发送字符串喜欢  " \b \b"
将删除一个字符,光标将占据删除字符位置。


最好的问候,


Neil胡


I have a project that uses a PIC24 microconrtller connected to the PC via RS232 (UART in PIC eze). The form sends commands to the controller which repsonds and then sends back data. One of the commands is a sort of count down timer. The controller counts down from 9 to 0. What I am trying to do is have the controller send a backspace command to the C# form and then display the next number, that way there is no need to clear and reprint everything. The problem is that I can't seem to find the right value to send to the C# form to get an actual backspace. I have tried sending \b and 0x08, but what I get i either a space or a weird looking diamond like character.

Does anyone have any idea how to send a backspace character via RS232?

解决方案

Hello mityeltu,

Maybe you need to define a match format between encoding and decoding. In C# could be done like this. Before sending you could get byte and when receiving convert it to chars.

           var bytes= Encoding.ASCII.GetBytes("\b \b");

           var chars= Encoding.ASCII.GetString(bytes);

And also you could try to send string like "\b \b", which will delete a character and cursor will occupy delete-character position.

Best Regards,

Neil Hu


这篇关于带串行PIC单片机的C#表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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