views:

392

answers:

3

I am trying to parse some output data from and PBX and I have found something that I can't really figure out. In the documentation it says the following

Information for type of call and feature. Eight character for ’status information 3’ with following ASCII values in hexadecimal notation.

1. Character 
Bit7 Incoming call 
Bit6 Outgoing call 
Bit5 Internal call 
Bit4 CN call
2. Character 
Bit3 Transferred call (transferring party inside) 
Bit2 CN-transferred call (transferring party outside) 
Bit1 
Bit0

Any ideas how to interpret this? I have no raw data at the time to match against but I still need to figure it out.

A: 

Eight character for ’status information 3’ with following ASCII values in hexadecimal notation.

If think this means the following.

  1. You will get 8 bytes - one byte per line, I guess.
  2. It is just the wrong term. They mean two hex digits per byte but call them characters.

So it is just a byte with bit flags - or more precisely a array of eight such bytes.

Bit

7  incoming
6  outgoing
5  internal
4  CN
3  transfered
2  CN transfered
1  unused?
0  unused?

You could map this to a enum.

[BitFlags]
public enum CallInformation : Byte
{
    Incoming     = 128,
    Outgoing     =  64,
    Internal     =  32,
    CN           =  16
    Transfered   =   8,
    CNTransfered =   4,
    Undefined    =   0
}
Daniel Brückner
+2  A: 

Probably you'll receive two characters (hex digits: 0-9, A-F) First digit represents the hex value for the most significant 4 bits, next digit for the least significant 4 bits.

Example: You will probably receive something like the string "7C" as hex representation of the bitmap: 01111100.

Cătălin Pitiș
A: 

Very hard without data. I'd guess that you will get two bytes (two ASCII characters), and need to pick them apart at the bit level.

For instance, if the first character is 'A', you will need to look up its character code (65, or hex 0x41), and then look at the bits. Of course the bits are the same regardless of decimal or hex, but its easer to do by hand in hex. 0x41 is bit 5 and bit 1 set, so that would be an "internal call". Bit 1 seems undocumented.

I'm not sure why it looks as if that would require two characters; it's only eight bits documented.

unwind