LECPServer icon indicating copy to clipboard operation
LECPServer copied to clipboard

如何读写Int16(Short)等类型?

Open tiaod opened this issue 3 years ago • 3 comments

根据jlean的文档,它支持读写这些类型: image 但是在LECPServer,却只支持这些: image

tiaod avatar Apr 28 '21 09:04 tiaod

是的,我们只针对一般用到的类型写在了LECPServer里面,省略了大部分类型,PLC一般不会用到int32和int64这种类型的,如果需要用到,欢迎修改main.js实现,其实也很简单 @tiaod 😄

xeden3 avatar May 03 '21 17:05 xeden3

原来如此,但我这边公司项目用到了short类型,我添加后提个pr吧😄

tiaod avatar May 04 '21 00:05 tiaod

你好,我建议你可以考虑使用后段程序,将WORD(UINT16) 转为 Short(INT16),就是将无符号整数转为有符号的整数,算法相对很简单,PHP、JS、Python都有现成的算法。

https://stackoverflow.com/questions/872424/unsigned-int-to-signed-in-php https://stackoverflow.com/questions/16452232/how-to-convert-signed-32-bit-int-to-unsigned-32-bit-int

当然看看你具体的需求是什么,还有后台程序使用的是哪个语言。

其实我也考虑将Short和Int32、Int64加入到LECPServer中,但这个不是最优先级的。

当然也欢迎你PR一个,这个实现代码并不难。

xeden3 avatar May 04 '21 14:05 xeden3