Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JadoonJee opened this issue Jan 9, 2024 · 2 comments
Open

Comments

@JadoonJee
Copy link

JadoonJee commented Jan 9, 2024

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…

@LBCQ123
Copy link

LBCQ123 commented Jan 10, 2024

//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]);

@JadoonJee
Copy link
Author

//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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants