dsm-api-v2
ds.h
Go to the documentation of this file.
00001 /*
00002  This file is part of the digitalSTROM ds485-core library.
00003 
00004  Copyright (C) 2010 digitalSTROM.org, Schlieren, Switzerland
00005 
00006  digitalSTROM ds485-core library is free software; you can redistribute it and/or
00007  modify it under the terms of the GNU General Public License
00008  as published by the Free Software Foundation version 2
00009  of the License.
00010 
00011  digitalSTROM ds485-core library is distributed in the hope that it will be useful,
00012  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  GNU General Public License for more details.
00015 
00016  You should have received a copy of the GNU General Public License
00017  along with digitalSTROM ds485-core library; if not, write to the Free Software
00018  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019  */
00020 
00021 #ifndef _dsid_h
00022 #define _dsid_h
00023 
00024 #if defined(__GNUC__)
00025 #include <stdio.h>
00026 #include <string.h>
00027 #include <stdint.h>
00028 #include <sys/types.h>
00029 #include <unistd.h>
00030 #include <sys/time.h> 
00031 #elif defined(__MSVC__)
00032 #endif
00033 
00037 typedef struct {
00038     unsigned char id[12];
00039 } dsid_t;
00040 
00041 #define IsBroadcastId(id) \
00042     (memcmp("\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", &(id), sizeof(dsid_t)) == 0)
00043 
00044 #define IsEqualId(id1, id2) \
00045     (memcmp(&(id1), &(id2), sizeof(dsid_t)) == 0)
00046 
00047 #define SetBroadcastId(id) \
00048     memcpy(&(id), "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", sizeof(dsid_t))
00049 
00050 #define SetNullId(id) \
00051     memcpy(&(id), "\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(dsid_t))
00052 
00053 #define IsNullId(id) \
00054     (memcmp("\0\0\0\0\0\0\0\0\0\0\0\0", &(id), sizeof(dsid_t)) == 0)
00055 
00056 #if defined(__linux__)
00057 # define BSP_MS_PER_TICKS 10
00058 #elif defined(__APPLE__)
00059 # define BSP_MS_PER_TICKS 10
00060 #elif defined(__CYGWIN__)
00061 # define BSP_MS_PER_TICKS 10
00062 #endif
00063 
00064 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines