File: AdmHndlr.c

package info (click to toggle)
slbreflex 2.2.0-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 200 kB
  • ctags: 200
  • sloc: ansic: 1,523; makefile: 79; sh: 73
file content (58 lines) | stat: -rwxr-xr-x 1,285 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*****************************************************************
/
/ File   :   AdmHndlr.c
/ Author :   David Corcoran
/ Date   :   October 15, 1999
/ Purpose:   This handles administrative functions like reset/power.
/            See http://www.linuxnet.com for more information.
/ License:   See file LICENSE
/
******************************************************************/

#include "LinuxDefines.h"
#include "AdmHndlr.h"
#include "serial.h"


ULONG Adm_SetWWT( ULONG ulWWT ) {
  IO_UpdateReturnBlock( ulWWT );
  return STATUS_SUCCESS;
}

ULONG Adm_SetMode( ULONG ulMode, ULONG ulWWT ) {

  unsigned char pcSetModeA[6] = {0x61, 0x00, 0x00, 0x10, 0x00, 0x00};
  unsigned char pcSetModeB[6] = {0x61, 0x10, 0x00, 0x00, 0x4D, 0x00};  
  unsigned char pcSetMode[6];
  char BackByte;
  int i;

  if ( ulMode == 0 ) {
    memcpy(pcSetMode, pcSetModeA, 6);
  } else if ( ulMode == 1 ) {

  if ( ulWWT > 0 ) {
    pcSetModeB[1] = 0x11;
    pcSetModeB[5] = ulWWT;
  }

  memcpy(pcSetMode, pcSetModeB, 6);

  } else {
    return STATUS_UNSUCCESSFUL;
  }

  for (i=0; i<6; i++) {
    if ( IO_Write(pcSetMode[i]) ) {
      if ( IO_Read( 1, &BackByte ) ) {
	if ( BackByte == 0x62 ) {
	  continue;
	} else {
	  return STATUS_UNSUCCESSFUL;
	}
      }
    }
  }

  return STATUS_SUCCESS;  
}