utopiantools / node-visca Goto Github PK
View Code? Open in Web Editor NEWAdvanced nodejs library for working with VISCA-based PTZ cameras over IP and over serial connections.
Advanced nodejs library for working with VISCA-based PTZ cameras over IP and over serial connections.
Hi. Great work. Thank you. Is there any chance you could provide a basic usage example for Visca over IP please?
Hi @jeffmikels ๐
Firstly, thanks for your work on this project! ๐
Today I used patch-package to patch @utopian/[email protected]
for the project I'm working on.
When using the UDP Transport, my application would always crash when creating a new Camera
object. The following patch should fix that.
It also disables the console.log
output.
Here is the diff that solved my problem:
diff --git a/node_modules/@utopian/visca/dist/visca-ip.js b/node_modules/@utopian/visca/dist/visca-ip.js
index 8b20046..146feec 100644
--- a/node_modules/@utopian/visca/dist/visca-ip.js
+++ b/node_modules/@utopian/visca/dist/visca-ip.js
@@ -105,11 +105,11 @@ class UDPTransport extends events_1.EventEmitter {
if (this.debug)
console.log('Sent: ' + packet);
// sending packet
- this.socket.send(packet, this.port, this.host, function (error) {
+ this.socket.send(Buffer.from(packet), this.port, this.host, (error) => {
if (error) {
this.socket.close();
}
- else {
+ else if(this.debug) {
console.log('Data sent !!!');
}
});
This issue body was partially generated by patch-package.
Note that this auto-generated diff fixes the compiled js, but I don't think it is hard to find that lines in the TS.
Would you accept a PR?
When testing the library with a Prisual 20x Camera using UDP Visca I am receiving a syntax error sending the Preset Recall command and Preset Set Commands.
Here is the code
import { Camera } from "../src/visca/visca";
import { ViscaController,ViscaCameraConfig, ViscaControllerConfig,ViscaCommand } from "../src/visca/visca";
let config = {
viscaSerial:{port:"COM7",baud:9600},
//viscaIPCameras: [],
viscaServer:{basePort: 52381,}
}
let ipConfig = {
} as ViscaCameraConfig;
let viscaConfig = config as ViscaControllerConfig;
viscaConfig.viscaSerial.baud = 9600;
viscaConfig.viscaSerial.port = "COM7";
ipConfig.id = 1;
ipConfig.ip = "192.168.100.88";
ipConfig.name= "Test";
ipConfig.port=1259;
const controller = new ViscaController(viscaConfig);
let cam1 = controller.addIPCamera(ipConfig);
cam1.on('update',()=>{
console.log('cam 1 updated:');
console.log(JSON.stringify(cam1));
});
let cmd = ViscaCommand.cmdCameraPresetRecall(1,1);
console.log(JSON.stringify(cmd));
cmd = ViscaCommand.cmdCameraPresetSet(1,1);
console.log(JSON.stringify(cmd));
cmd.onError = function(err){
console.log(`preset error: ${err}`);
};
cam1.sendCommand(cmd);
console.log("started")
Attached is the log output.
node-visca.log
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.