vdr  1.7.27
hdffcmd_base.c
Go to the documentation of this file.
00001 /**********************************************************************
00002  *
00003  * HDFF firmware command interface library
00004  *
00005  * Copyright (C) 2011  Andreas Regel
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the
00019  * Free Software Foundation, Inc.,
00020  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00021  *
00022  *********************************************************************/
00023 
00024 #include "hdffcmd_base.h"
00025 
00026 void HdffCmdBuildHeader(BitBuffer_t * MsgBuf, HdffMessageType_t MsgType,
00027                         HdffMessageGroup_t MsgGroup, HdffMessageId_t MsgId)
00028 {
00029     BitBuffer_SetBits(MsgBuf, 16, 0); // length field will be set later
00030     BitBuffer_SetBits(MsgBuf, 6, 0); // reserved
00031     BitBuffer_SetBits(MsgBuf, 2, MsgType);
00032     BitBuffer_SetBits(MsgBuf, 8, MsgGroup);
00033     BitBuffer_SetBits(MsgBuf, 16, MsgId);
00034 }
00035 
00036 uint32_t HdffCmdSetLength(BitBuffer_t * MsgBuf)
00037 {
00038     uint32_t length;
00039 
00040     length = BitBuffer_GetByteLength(MsgBuf) - 2;
00041     MsgBuf->Data[0] = (uint8_t) (length >> 8);
00042     MsgBuf->Data[1] = (uint8_t) length;
00043 
00044     return length + 2;
00045 }