UBP FT DATA frame layout example

hdrbits for UBP should be 24 (3 byte header).

Here's an example UBP ft_data frame layout. This example sends a 5-data-byte UBP message with the header 0x05,0x22,0x33 and data 0x55,0x66,0x77,0x88,0x99.


Frame Header: 
field name      offset           value 
------------------------------------------------------------------------- 
source          0                SD_CLIENT 
source channel  1                (client ID assigned during registration) 
destination     2                SD_CARD 
dest. channel   3                (channel # of UBP card) 

data length     4,5              0,24 (Length of the FT_DATA section) 
frame type      6                FT_DATA 
reserved        7                0 


Frame Body (FT_DATA): 
field name      offset           value 
------------------------------------------------------------------------- 
Header length   8                3 (3 byte header for UBP) 
Header bits     9                24 (3 byte header for UBP) 
Data length     10,11            0,5 (5 data bytes in this example) 

Extra length    12               0 
Mode            13               MODE_TX 
Priority        14               0 (ignored for tx frames) 
Status          15               0 (ignored for tx frames) 

Timestamp       16-19            0,0,0,0 (ignored for tx frames) 

Context         20               0 
Reserved        21-23            0,0,0 

(UBP frame data:) 

UBP header      24-26            0x05,0x22,0x33 
UBP data        27-31            0x55,0x66,0x77,0x88,0x99 

Note that the lower nibble of the first UBP header byte must equal the number of data bytes (05 in this case). Also please note that multibyte variables such as datalength or messagelength must go out on the network in network byte order. The gclient library functions such as gsend() take care of this conversion transparently.

Here is some example code in the context of the gclient library based example code found on the web site. This uses structures defined in include/frame.h and gclient/gclient.h in the example source code. This code assumes that a client connection has been established and that the client has registered with the gryphon server and received a client id. This function would be called with the UPB channel as the first argument, the client ID in the second argument, and the file descriptor of the server connection in the third argument.


void send_ubp(int channel, int client_id, int server_fd) 
{ 

        struct Msg m; 

        /* frame header setup */ 

        m.FH.src = SD_CLIENT; 
        m.FH.srcchan = client_id; 
        m.FH.dst = SD_CARD; 
        m.FH.dstchan = channel; 
        m.FH.msglen = 24; 
        m.FH.frametype = FT_DATA; 

        /* FT_DATA setup */ 

        m.DH.hdrlen = 3; 
        m.DH.hdrbits = 24; 
        m.DH.datalen = 5; 
        m.DH.extralen = 0; 
        m.DH.mode = MODE_TX; 
        m.DH.priority = 0; 
        m.DH.stat = 0; 
        m.DH.time = 0; 
        m.DH.context = 0; 

        /* UBP frame header/data: */ 

        m.DD[0] = 0x05; 
        m.DD[1] = 0x22; 
        m.DD[2] = 0x33; 
        m.DD[4] = 0x55; 
        m.DD[5] = 0x66; 
        m.DD[6] = 0x77; 
        m.DD[7] = 0x88; 
        m.DD[8] = 0x99; 

        /* Send the frame */ 

        gsend(server_fd, &m); 
} 

This document was obtained from:

Dearborn Group, Inc.
(248) 488-2080
dg@dgtech.com
http://www.dgtech.com

Copyright © 2003 Dearborn Group Inc.