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.