Bitstring and octetstring in Tau G2

Source: Internet
Author: User
Tau G2 has more predefined classes than common UML tools, such as bitstring and octetstring. These classes correspond to ASN.1, mainly to facilitate the processing of PDU encoding, which is designed for communication protocol software development. We generally like to use the bitstring class because it is more convenient and intuitive. However, a small problem recently encountered is that when processing long PDU strings using the bitstring class, it is sometimes unable to be passed to the environment function. To solve this problem, one solution is to use the octetstring class.

The bitstring class stores one bit in one byte in memory, while the octetstring class stores eight bits in one byte. It can be seen that the etstring class saves more memory, therefore, it is more advantageous to communicate with environment functions.We recommend that you use octetstring In the Signal Parameter definition of environment functions..

In Tau G2, it is easy to convert bitstring and octetstring.

Bitstring B, P;
Octetstring S;

B= '010'B;
S=Octetstring (B );//Convert bitstring to octetstring
P=S. bitstring (s );//Convert octetstring to bitstring

When bitstring is converted to octetstring, if the length of bitstring is not a multiple of 8, Tau G2 will add zero after bitstring. For the above example, s will be '000000' B.

in the C Code generated by Tau G2, bitstring and octetstring are actually one thing, so after using octetstring instead of bitstring, the vast majority of the Code in the environment function does not need to be modified. It is only worth noting that each element in the bits array of octetstring is no longer 0 and 1, but a number between 0 and 255.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.