cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Working with BLOB in Services

Chrischhan
12-Amethyst

Working with BLOB in Services

Hi,

 

i get properties from a remote device (edge) via C-SDK.

There is one property of Type blob (byteArray) which contains multiple (0-32) bytes.

How can i work with blob?

How can i do some bit logic, like check if bit "18" is set?

 

Checks on the edge Device is not possible because bytes have a different meaning from device to device. Only the Plattform knows how to interpret the bytes

1 ACCEPTED SOLUTION

Accepted Solutions

i found a solution for my Problem:

an abstract code to identify single bits:

let length = blob.length;

result = "length: " + length + " | ";

for (var i = 0; i < length; i++) {
result += blob[i].toString(2) + " ";
}

 the rest is some string magic

View solution in original post

5 REPLIES 5
mgoel
17-Peridot
(To:Chrischhan)

@Chrischhan 

 

Thank you for reaching out to us. ThingWorx is capable to handle utf-8 encoding.

 

As per my understanding data you are getting from device is already encrypted in ASC characters right? What kind of data type actually it is ex: string or numeric. 

 

Now once Thingworx receives this data it will show question marks or any other symbol for special characters other than utf-8 format. Please check below article it might helpful to you:

https://www.ptc.com/en/support/article/CS224103

 

Do let me know for further questions.

Regards,

Mohit 

Chrischhan
12-Amethyst
(To:mgoel)

Thanks for the answer but unfortunately this does not answer my problem.

 

I have attached a screenshot for illustration.
I assign the input parameter of type blob to the variable result. the for loop afterwards does nothing. How can I work with BLOB in Services? How can I process the input?

By the way: the outputstring does not change if I change the blob from "asd" to for example "123".

 

Chrischhan_0-1622102270185.png

 

 

mgoel
17-Peridot
(To:Chrischhan)

@Chrischhan 

 

Not sure if this matches your exact requirement. Check this article: https://www.ptc.com/en/support/article/CS335300

 

Regards,

Mohit

Chrischhan
12-Amethyst
(To:mgoel)

It is going in the right direction, however the problem is not to package the data in BLOB and send it to the platform.
The problem is I want to process the BLOB data within a TWX service.

i found a solution for my Problem:

an abstract code to identify single bits:

let length = blob.length;

result = "length: " + length + " | ";

for (var i = 0; i < length; i++) {
result += blob[i].toString(2) + " ";
}

 the rest is some string magic

Top Tags