S7NetPlus/s7netplus

Reading String from Siemens Plc and dispplay that in unity object text

JadoonJee opened this issue · 2 comments

Hi Everyone
I am having a problem with reading string from Siemens S71500 PLC, I am actually not sure how to read that in unity as a string.
What I want to do is read a string name and then I want to display that in unity TextMashPro.
I have written something like this but no luck, I am getting a strange message like this System.Byte[]
My Db number is 647 and starting address is 31090 which is define as string and reading first 40 bytes, and using S7.net library
In a debug result of unity i get System.Byte[]
Can someone please help me out.

                var bytes = plc.ReadBytes(DataType.DataBlock, 647, 31090, 40);
                string numb1 = Convert.ToString(bytes);
                Debug.Log(numb1);

Kind Regards

text3
text2
text
Uploading text4.PNG…

//Try to use this
bytes = plc.SieMens.ReadBytes(mType, (int)mAddr.mDBNumber, (int)mAddr.mDBOffset, MaxLenth + 2);
var gbk = Encoding.GetEncoding("GBK");
ret = gbk.GetString(bytes, 2, bytes[1]);

//Try to use this bytes = plc.SieMens.ReadBytes(mType, (int)mAddr.mDBNumber, (int)mAddr.mDBOffset, MaxLenth + 2); var gbk = Encoding.GetEncoding("GBK"); ret = gbk.GetString(bytes, 2, bytes[1]);

Will try that one thank you very much