Integrating ubjson with jsonrpc

58 views
Skip to first unread message

Brad Andersen

unread,
Oct 9, 2014, 1:17:48 PM10/9/14
to universal-...@googlegroups.com
I'm trying to transfer uint8 data through a UART interface while using jsonrpc (tinyrpc).  I'm attempting use of simpleubjson to encode the data such that the jsonrpc will accept and form its string to send through the UART.

Is there any examples of this type of thing?

A bit more information:
it is a BeagleboneBlack communicating (and controlling) a PIC24 microcontroller
using Python on BBB acting as client
using C on PIC24 acting as server

Thanks for your help.
Brad

Riyad Kalla

unread,
Oct 9, 2014, 1:19:34 PM10/9/14
to universal-...@googlegroups.com
Interesting - Alex, any ideas?

--
You received this message because you are subscribed to the Google Groups "Universal Binary JSON (UBJSON)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to universal-binary...@googlegroups.com.
To post to this group, send email to universal-...@googlegroups.com.
Visit this group at http://groups.google.com/group/universal-binary-json.
For more options, visit https://groups.google.com/d/optout.

Brad Andersen

unread,
Oct 9, 2014, 1:28:29 PM10/9/14
to universal-...@googlegroups.com
Maybe I don't understand the usage of ubjson.  I thought that was the idea (partly) to send uint8 data through a JSON pipe, no?

--
You received this message because you are subscribed to a topic in the Google Groups "Universal Binary JSON (UBJSON)" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/universal-binary-json/gv1bIv-jqwA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to universal-binary...@googlegroups.com.

To post to this group, send email to universal-...@googlegroups.com.
Visit this group at http://groups.google.com/group/universal-binary-json.
For more options, visit https://groups.google.com/d/optout.



--
Brad Andersen
Systems Engineer
Lite-Check, LLC
3102 E Trent Ave
Spokane, WA 99202


CONFIDENTIALITY: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain LITE-CHECK confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

Riyad Kalla

unread,
Oct 9, 2014, 1:37:42 PM10/9/14
to universal-...@googlegroups.com
UBJSON is a binary format that is 1:1 compatible with JSON - if you need to efficiently send large payloads of JSON, keeping them in UBJSON format and generating/parsing them on either end is much faster.

The big benefit of UBJSON is that while maintaing the 1:1 compatibility with JSON, it also managed to add binary data support without losing that compatibility (which every other binary json format does) and that support is done through sending uint8 values - so that is a very small aspect of the spec.


Brad Andersen

unread,
Oct 9, 2014, 1:49:26 PM10/9/14
to universal-...@googlegroups.com
I think I'm confused by what 1:1 compatibility means.

It appears that UBJSON doesn't encode uint8 data in such a way that a JSON encoder will accept it.  But UBJSON can accommodate JSON data and uint8 data, is this what you mean?

Alexander Shorin

unread,
Oct 9, 2014, 2:39:01 PM10/9/14
to universal-...@googlegroups.com
Hi Brad,

I believe you're confused by what UBJSON is. First, it's completely different, binary format and you wouldn't be able to use it with JSONRPC services since they're only accepts JSON data, not UBJSON. However, in the same time UBJSON is compatible with JSON. But that doesn't means that you're able to pass UBJSON data to JSON decoder and it will accept it. No. This means, that same data structures in UBJSON are logically equal to the same in JSON. So you can safely replace JSON with UBJSON and nothing will changed for you expect of more compact data representation in binary form. But you should do this both on client and server sides, so actually you'll need ubjsonrpc service which would be easy to write (actually, easy to patch jsonrpc one).

As for simpleubjson, it supports uint8 data and will automagically encode any integer values in range 0-255 into it.


--
,,,^..^,,,

Brad Andersen

unread,
Oct 9, 2014, 2:51:49 PM10/9/14
to universal-...@googlegroups.com
Ah, I think I'm getting it.  So I have a couple choices:
  1. use the RPC routines, but replace the JSON encoder/decoder stuff with UBJSON equivalents
  2. use some binary2ascii encode/decode (e.g., BASE64) and pass that to the JSON handlers
I'm not aware of any RPC built on UBJSON, do you?

Guess I'll check out the two alternatives.

Alexander Shorin

unread,
Oct 9, 2014, 2:55:03 PM10/9/14
to universal-...@googlegroups.com
I'm not aware too, but it's a good chance to make it first (;
As for choices, only the first is reasonable to use. Otherwise there is no much profit from using UBJSON.

--
,,,^..^,,,
Reply all
Reply to author
Forward
0 new messages