Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Reading and Writing a ByteString
June 21, 2016
11:20, EEST
Avatar
hcvoort
Member
Members
Forum Posts: 5
Member Since:
June 21, 2016
sp_UserOfflineSmall Offline

Hello,

I want to read a value which is a struct on the real time side. If I read the datatype from within an android application it is represented as bytestring. How do I handle reading and writing the individual components of the bytestring in java?
Thanks a lot.

BR,

Carsten Voort

June 21, 2016
12:39, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

If the DataType Attribute is a ByteString then from OPC UA’s perspective it is just a series of bytes. It is a scalar type that consists of an array of bytes that can only be Read/Write completely not in parts (similarly as a String is in programming languages a series of characters). An OPC UA ByteString will map to byte[] in Java. Therefore it can be accessed like any other java array e.g. first element

DataValue dv = (from the read call)
byte[] bs = (byte[]) dv.getValue().getValue(); //assuming it is a ByteString
byte element0 = bs[0];

Please let me know if my interpretation of your question was wrong.

– Bjarne

June 21, 2016
14:34, EEST
Avatar
hcvoort
Member
Members
Forum Posts: 5
Member Since:
June 21, 2016
sp_UserOfflineSmall Offline

Hello Bjarne,

Thank you for responding. The cast indeed does the job. How about writing to this same NodeId with a bytestring?

BR,

Carsten Voort

June 21, 2016
15:18, EEST
Avatar
hcvoort
Member
Members
Forum Posts: 5
Member Since:
June 21, 2016
sp_UserOfflineSmall Offline

hcvoort said
Hello Bjarne,

Thank you for responding. The cast indeed does the job. How about writing to this same NodeId with a bytestring?

BR,

Carsten Voort  

Hi Bjarne,

I already figured it out 🙂

-Carsten

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
8 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

TimK: 41

Member Stats:

Guest Posters: 0

Members: 683

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

digitechroshni, LouieWreve, Kickbiche, karrimacvitie5, graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma

Moderators: Jouni Aro: 1010, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1