Revision dc472500 toolbox/main.c

View differences:

toolbox/main.c
57 57
      if (get_coil(MB_COIL_EN)) {
58 58
        tool_enable();
59 59
        toolstate = TS_ON;
60
      } else if (!get_coil(MB_COIL_NEW)) {
61
        toolstate = TS_OFF;
60 62
      }
61 63
      break;
62 64

  
......
84 86
      } else if (rfid_check_serno(current_user)) {
85 87
        toolstate = TS_ON;
86 88
      } else {
87
        // TODO blink yellow for 10 seconds or something
88
        set_coil(MB_COIL_EN, 0);
89
        tool_disable();
90
        toolstate = TS_OFF;
89
        if (led_blink_done()) {
90
          set_coil(MB_COIL_EN, 0);
91
          tool_disable();
92
          toolstate = TS_OFF;
93
        }
91 94
      }
92 95
      break;
93 96

  
......
99 102
        toolstate = TS_REQ_DIS;
100 103
      } else if (!rfid_check_serno(current_user)) {
101 104
        toolstate = TS_MISSING_ID;
105
        led_blink_start();
102 106
      }
103 107
      break;
104 108

  
......
109 113
eMBErrorCode eMBRegCoilsCB(UCHAR *reg_buf, USHORT addr, USHORT n_coils,
110 114
    eMBRegisterMode mode) {
111 115

  
116
  addr--;
117

  
112 118
  if (addr+n_coils > N_COILS) {
113 119
    return MB_ENOREG;
114 120
  }
......
153 159

  
154 160
  } else if (mode == MB_REG_READ) {
155 161

  
156
    reg_buf[0] = (coils >> (addr-1)) & ((1 << n_coils) - 1);
162
    reg_buf[0] = (coils >> addr) & ((1 << n_coils) - 1);
157 163
    return MB_ENOERR;
158 164

  
159 165
  }
......
167 173

  
168 174
eMBErrorCode eMBRegInputCB(UCHAR *reg_buf, USHORT addr, USHORT n_regs) {
169 175

  
176
  addr--;
177

  
170 178
  switch (addr) {
171 179

  
172 180
    case MB_INP_SERNOL:
......
226 234
      rfid_get_serno(current_user);
227 235
      rfid_start_read();
228 236
    }
229
    //tool_main();
237
    tool_main();
230 238
    eMBPoll();
231 239
    _delay_ms(50);
232 240
  }

Also available in: Unified diff