Hi Everyone!
I recently discovered that the values returned by get_pantilt_position() are shifted one packer, i.e. * 16 the actual value on debian stable 64 bit.
I fixed this as follows:
VISCA_API uint32_t
VISCA_get_pantilt_position(VISCAInterface_t iface, VISCACamera_t camera, int pan_position, int tilt_position)
{
VISCAPacket_t packet;
uint32_t err;
uint16_t pan_pos, tilt_pos;
int i;
_VISCA_init_packet(&packet);
_VISCA_append_byte(&packet, VISCA_INQUIRY);
_VISCA_append_byte(&packet, VISCA_CATEGORY_PAN_TILTER);
_VISCA_append_byte(&packet, VISCA_PT_POSITION_INQ);
err=_VISCA_send_packet_with_reply(iface, camera, &packet);
if (err!=VISCA_SUCCESS)
return err;
else
{
pan_pos = ((iface->ibuf[2] & 0xf) << 12) + ((iface->ibuf[3] & 0xf) << 8) + ((iface->ibuf[4] & 0xf) << 4) + (iface->ibuf[5] & 0xf);
tilt_pos = ((iface->ibuf[6] & 0xf) << 12) + ((iface->ibuf[7] & 0xf) << 8) + ((iface->ibuf[8] & 0xf) << 4) + (iface->ibuf[9] & 0xf);
if (pan_pos<0x8000) *pan_position=pan_pos; else *pan_position=((int)pan_pos) - 65536; if (tilt_pos<0x8000) *tilt_position=tilt_pos; else *tilt_position=((int)tilt_pos) - 65536; return VISCA_SUCCESS; }
}
However that may break the function on other systems. I really do not know what is going on. Maybe this should be only if iface->bytes==11 ?
It would be interesting to know what systems this works on.
Regards,
Axel
Hi Axel,
I haven't used a VISCA camera in years and I don't have a VISCA camera so I can't really test anything ;(