Skip to content

Commit 88ede6f

Browse files
committed
disable ack for old cams
1 parent 509ed98 commit 88ede6f

3 files changed

Lines changed: 48 additions & 3 deletions

File tree

examples/old_model/old_model.ino

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include "Arduino.h"
2+
#include <Pelco_And_Arduino.h>
3+
4+
/*
5+
This exemple is based on the simple example from examples\simple\simple.ino
6+
However, it is designed for the old model of the Pelco cameras.
7+
The old models works in the protocol RS422 so it need 2 pair of cable to communicate.
8+
If you have only one pair (preferably for sending commands), you can disable acknoledge when sending commands
9+
10+
*/
11+
12+
PelcoCamBus MyPelcoBus(6, // TX pin (Arduino to Cam)
13+
7, // RX pin (Cam to Arduino)
14+
8); // RE pin for manual switching modules set to -1 if it is a auto module (like a groove one)
15+
16+
void setup() {
17+
18+
Serial.begin(9600);
19+
20+
// Begin the serial communication
21+
MyPelcoBus.begin(PELCO_D9600, true);
22+
23+
// Send stop, send_command will return a bool that indicates if the cameras sended its ACK
24+
// It's a good way to see if the camera is plugged in
25+
while (!MyPelcoBus.send_command(1, STOP)) {
26+
Serial.println("Camera not plugged?");
27+
delay(1000);
28+
}
29+
Serial.println("Init Finished!");
30+
}
31+
32+
void loop() {
33+
34+
//Pan to the left with max speed before turbo
35+
MyPelcoBus.send_command(1, PAN_L, 0x3F, 0x00, true);
36+
delay(1000);
37+
MyPelcoBus.send_command(1, STOP); //Stop the camera
38+
delay(1000);
39+
//Pan to the left with less speed than the tilt speed that goes up
40+
MyPelcoBus.send_command(1, PAN_L_TILT_U, 0x10, 0xFF, true);
41+
delay(1000);
42+
MyPelcoBus.send_command(1, STOP); //Stop the camera
43+
delay(1000);
44+
}

src/Pelco_And_Arduino.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void PelcoCamBus::begin(uint32_t config, bool log_messages = false) {
9999
*/
100100

101101
bool PelcoCamBus::send_command(uint8_t address, uint8_t command, uint16_t data1 = 0x00, uint8_t data2 = 0x00,
102-
bool request) {
102+
bool disableACK) {
103103
messToCamera[0] = 0xFF; // The first byte is always FF (sync)
104104
messToCamera[1] = address; // the second is the adress
105105

@@ -158,7 +158,7 @@ bool PelcoCamBus::send_command(uint8_t address, uint8_t command, uint16_t data1
158158

159159
(*SerialCamBus).write(messToCamera, sizeof(messToCamera)); // Write to the camera
160160

161-
if (!request) { // Check the response of the camera only if it isn't a request (aka a query aka check for ack)
161+
if (!disableACK) { // Check the response of the camera only if it isn't a request (aka a query aka check for ack)
162162
int timeout = 10000; // 10 millissecond wait
163163

164164
if (!autoModule_)

src/Pelco_And_Arduino.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class PelcoCamBus
2828
uint16_t rxPin_;
2929
uint16_t rePin_;
3030

31+
bool support_rx_;
3132
bool log_messages_;
3233
bool autoModule_;
3334

@@ -67,7 +68,7 @@ class PelcoCamBus
6768
PelcoCamBus(uint8_t rxPin, uint8_t txPin, uint8_t readEnPin = NOT_A_PIN);
6869
void begin(uint32_t config, bool log_messages = false);
6970

70-
bool send_command(uint8_t address, uint8_t command, uint16_t data1 = 0x00, uint8_t data2 = 0x00, bool request = false);
71+
bool send_command(uint8_t address, uint8_t command, uint16_t data1 = 0x00, uint8_t data2 = 0x00, bool disableACK = false);
7172
uint16_t send_request(uint8_t address, uint8_t request, int timeout = 1000);
7273
bool send_raw(String hex_string); // TODO: get ACK
7374
};

0 commit comments

Comments
 (0)