

Overall product rating out of 5: 5.00
Based on 5 reviews
Write Review
Sort
Clear Filters
Order By
Newest First
Oldest First
Most Popular
Highest Rating
Breakdown
5
0
0
0
0
Product Reviews
RS485 PiZero addon
Reviewer didn't leave any comments
Was this review helpful?
5 months ago
RS485 PiZero addon
I bought this as a means to control a traditional (so not networked) PTZ camera (the Hikvision HiLook PTZ-T4255I-D) - I was able to write my own API to control the camera using Pelco-D, although I would caution that there isn't actually a need to use the RS485 class in the PySerial library - my example of the control script is below:
import serial
import sys
# This function takes a command string and sends individual bytes.
def switch_cmd(argument):
switcher = {
"stop": (0,0),
"up": (0,8),
"ul": (0,12),
"ur": (0,10),
"down": (0,16),
"dl": (0,20),
"dr": (0,18),
"left": (0,4),
"right": (0,2),
"zoomout": (0,64),
"zoomin": (0,32),
"focusout": (0,128),
"focusin": (1,1),
"setpreset": (0,3),
"clearpreset": (0,5),
"callpreset": (0,7)
}
return switcher.get(argument, (0,0))
def do_hex(hexlist):
out_hex=""
for eachitem in hexlist:
out_hex=out_hex+("{0:#04x}".format(int(eachitem))[2:])
return out_hex
def assemble_cmd(cmd,val1,val2):
header=0xff
channel=0x01
byte1,byte2=switch_cmd(cmd)
checksum=(header+channel+byte1+byte2+val1+val2)%256
return do_hex([header,channel,byte1,byte2,val1,val2,checksum])
def stop():
return bytearray.fromhex(assemble_cmd(switch_cmd("stop"),0,0))
def send_cmd(cmd,val1,val2,duration):
cmd_string=assemble_cmd(cmd,val1,val2) ser=serial.Serial(port='/dev/serial0',baudrate=2400,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS)
print (cmd," ",str(val1),".",str(val2),": ",cmd_string,"for ",duration," ms")
cmd_bytes = bytearray.fromhex(cmd_string)
ser.write(cmd_bytes)
time.sleep(duration/1000)
ser.write(stop())
Was this review helpful?
4 years ago
RS485 PiZero addon
Workshop perfect!
Was this review helpful?
5 years ago
RS485 PiZero addon
Works flawless
Was this review helpful?
6 years ago
RS485 PiZero addon
I cant get a pi zero to test it with
Was this review helpful?
9 years ago
New content loaded