Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: thewknd/kellerbus
base: ec5d3953de
...
head fork: thewknd/kellerbus
compare: 94229fedc6
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Dec 06, 2011
thewknd Arduino 1.0 support
ec78207
thewknd Arduino 1.0 support
94229fe
Showing with 39 additions and 7 deletions.
  1. +38 −6 kellerbus.cpp
  2. +1 −1  kellerbus.h
View
44 kellerbus.cpp
@@ -2,7 +2,7 @@
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
*/
-#include "kellerbus.h"
+#include <kellerbus.h>
CKellerBus::CKellerBus(HardwareSerial* mComm, unsigned long pBaudrate,unsigned char RTS){
@@ -35,6 +35,13 @@ unsigned short CKellerBus::Open()
unsigned short CKellerBus::initDevice(unsigned char Device)
{
unsigned short ret;
+ unsigned long b=0;
+
+ // Clear TxBuffer;
+ for(b = 0; b < COMM_TX_MAX; b++) {
+ TxBuffer[b] = 0;
+ }
+
Open();
cDevice = Device;
TxBuffer[0] = cDevice;
@@ -71,10 +78,19 @@ unsigned short CKellerBus::initDevice(unsigned char Device)
unsigned short CKellerBus::initDevice()
{
unsigned short ret;
+ unsigned long b=0;
+
+// Clear TxBuffer;
+ for(b = 0; b < COMM_TX_MAX; b++) {
+ TxBuffer[b] = 0;
+ }
+
Open();
TxBuffer[0] = cDevice;
TxBuffer[1] = 0b01111111 & 48;
+
+
if(TransferData(2,10) == COMM_OK) {
cClass = RxBuffer[2];
cGroup = RxBuffer[3];
@@ -106,6 +122,13 @@ unsigned short CKellerBus::initDevice()
unsigned short CKellerBus::readSerialnumber()
{
unsigned short ret;
+ unsigned long b=0;
+
+ // Clear TxBuffer;
+ for(b = 0; b < COMM_TX_MAX; b++) {
+ TxBuffer[b] = 0;
+ }
+
Open();
TxBuffer[0] = cDevice;
TxBuffer[1] = 0b01111111 & 69;
@@ -124,6 +147,12 @@ unsigned short CKellerBus::readChannel(unsigned char Channel)
unsigned char bteArr[4];
float value;
unsigned short ret;
+ unsigned long b=0;
+
+ // Clear TxBuffer;
+ for(b = 0; b < COMM_TX_MAX; b++) {
+ TxBuffer[b] = 0;
+ }
Open();
@@ -193,13 +222,13 @@ int CKellerBus::TransferData(unsigned short nTX, unsigned short nRX)
// End CRC16
digitalWrite(RTS_PIN,HIGH);
- delay(2);
+ delay(5);
Comm->write(TxBuffer,nTX + 2);
- delay(2);
+ delay(5);
digitalWrite(RTS_PIN,LOW);
-
+ delay(5);
delay_cnt = 0;
-
+ b = 0;
do {
if (Comm->available() > 0) {
RxBuffer[b] = Comm->read();
@@ -208,7 +237,8 @@ int CKellerBus::TransferData(unsigned short nTX, unsigned short nRX)
delay(1);
delay_cnt += 1;
} while(delay_cnt <= Timeout); // timeout max 105ms
- delay(2);
+
+
if(b == nRX) {
ret = COMM_OK;
@@ -216,6 +246,8 @@ int CKellerBus::TransferData(unsigned short nTX, unsigned short nRX)
ret = COMM_ERR_BAD_CRC;
}
+ delay(25);
+
return ret;
}
View
2  kellerbus.h
@@ -2,7 +2,7 @@
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
*/
-#include "WProgram.h"
+#include <Arduino.h>
#ifndef _H_KELLERBUS
#define _H_KELLERBUS

No commit comments for this range

Something went wrong with that request. Please try again.