Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

clean up

  • Loading branch information...
commit d8aafc7db92ee3ebd40b65bfb3807b04e366c481 1 parent 843c794
thewknd authored

Showing 1 changed file with 16 additions and 16 deletions. Show diff stats Hide diff stats

  1. +16 16 kellerbus.cpp
32 kellerbus.cpp
@@ -42,7 +42,6 @@ unsigned short CKellerBus::initDevice(unsigned char Device)
42 42 TxBuffer[b] = 0;
43 43 }
44 44
45   - Open();
46 45 cDevice = Device;
47 46 TxBuffer[0] = cDevice;
48 47 TxBuffer[1] = 0b01111111 & 48;
@@ -72,7 +71,7 @@ unsigned short CKellerBus::initDevice(unsigned char Device)
72 71 ret = COMM_ERR_BAD_CRC;
73 72 }
74 73 }
75   - Close();
  74 +
76 75 return ret;
77 76 }
78 77 unsigned short CKellerBus::initDevice()
@@ -85,12 +84,9 @@ unsigned short CKellerBus::initDevice()
85 84 TxBuffer[b] = 0;
86 85 }
87 86
88   - Open();
89 87 TxBuffer[0] = cDevice;
90 88 TxBuffer[1] = 0b01111111 & 48;
91   -
92   -
93   -
  89 +
94 90 if(TransferData(2,10) == COMM_OK) {
95 91 cClass = RxBuffer[2];
96 92 cGroup = RxBuffer[3];
@@ -116,7 +112,7 @@ unsigned short CKellerBus::initDevice()
116 112 ret = COMM_ERR_BAD_CRC;
117 113 }
118 114 }
119   - Close();
  115 +
120 116 return ret;
121 117 }
122 118 unsigned short CKellerBus::readSerialnumber()
@@ -129,7 +125,6 @@ unsigned short CKellerBus::readSerialnumber()
129 125 TxBuffer[b] = 0;
130 126 }
131 127
132   - Open();
133 128 TxBuffer[0] = cDevice;
134 129 TxBuffer[1] = 0b01111111 & 69;
135 130
@@ -139,7 +134,7 @@ unsigned short CKellerBus::readSerialnumber()
139 134 } else {
140 135 ret = COMM_ERR_BAD_CRC;
141 136 }
142   - Close();
  137 +
143 138 return ret;
144 139 }
145 140 unsigned short CKellerBus::readChannel(unsigned char Channel)
@@ -154,8 +149,6 @@ unsigned short CKellerBus::readChannel(unsigned char Channel)
154 149 TxBuffer[b] = 0;
155 150 }
156 151
157   - Open();
158   -
159 152 TxBuffer[0] = cDevice;
160 153 TxBuffer[1] = 0b01111111 & 73;
161 154 TxBuffer[2] = Channel;
@@ -182,7 +175,7 @@ unsigned short CKellerBus::readChannel(unsigned char Channel)
182 175 } else {
183 176 ret = COMM_ERR_BAD_CRC;
184 177 }
185   - Close();
  178 +
186 179 return ret;
187 180 }
188 181 int CKellerBus::TransferData(unsigned short nTX, unsigned short nRX)
@@ -221,12 +214,18 @@ int CKellerBus::TransferData(unsigned short nTX, unsigned short nRX)
221 214 TxBuffer[nTX+1]= Crc&0xFF;
222 215 // End CRC16
223 216
  217 + // Open HWSerial
  218 + Open();
  219 +
224 220 digitalWrite(RTS_PIN,HIGH);
225   - delay(5);
  221 + delay(3);
  222 +
226 223 Comm->write(TxBuffer,nTX + 2);
227 224 delay(5);
  225 +
228 226 digitalWrite(RTS_PIN,LOW);
229   - delay(5);
  227 + delay(3);
  228 +
230 229 delay_cnt = 0;
231 230 b = 0;
232 231 do {
@@ -245,8 +244,9 @@ int CKellerBus::TransferData(unsigned short nTX, unsigned short nRX)
245 244 } else {
246 245 ret = COMM_ERR_BAD_CRC;
247 246 }
248   -
249   - delay(25);
  247 +
  248 + // Close HWSerial
  249 + Close();
250 250
251 251 return ret;
252 252 }

0 comments on commit d8aafc7

Please sign in to comment.
Something went wrong with that request. Please try again.