jamlink.cpp 720 Bytes
Newer Older
1
2
#include "jamlink.h"

3
4
void printBinary(const unsigned short val)
{  
5
6
7
8
9
10
  for(int i = 15; i >= 0; i--)
    if(val & (1 << i))
      std::cout << "1";
    else
      std::cout << "0";
}
jcaceres's avatar
jcaceres committed
11
12
13



14
15
void printBinaryChar(const char* val) 
{
jcaceres's avatar
jcaceres committed
16
17
18
19
20
21
22
  for(int i = 7; i >= 0; i--)
    if(*val & (1 << i))
      std::cout << "1";
    else
      std::cout << "0";
}

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

//-------------------------------------------------------------------------------
/*! \brief Function to byteswap a char array
 *
 */
//-------------------------------------------------------------------------------
void byteSwap(char* bswp, int len) 
{
  char tmp;
  for (int i=0; i<(len/2); i++){
    tmp = bswp[2*i];
    bswp[2*i] = bswp[2*i+1];
    bswp[2*i+1] = tmp;
  }
}