开发者

serial port receiving data manipulation

开发者 https://www.devze.com 2023-03-22 16:39 出处:网络
In my application I am receiving data serially from com3 it is an integer variable, now I want to transfer this data in a form of string to com1 the string will be like \"#0 Pa\" here a is integer val

In my application I am receiving data serially from com3 it is an integer variable, now I want to transfer this data in a form of string to com1 the string will be like "#0 Pa" here a is integer value received from 'com3'.

I know how to receive and send data serially my code is working fine with it, but I am struck how can I form string code so it automatically take integer value received from com3 and send to com1, basically how I can formed st开发者_开发知识库ring with a variable value received and some character which are constant.


My question is: how do you receive the integer? Usually data is transferred as strings.

In case you do have it as an integer,

int receivedPar = ...;
string messageToSend = string.Format("#0 P{0}", receivedPar);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号