Skip to main content
October 9, 2011
Question

Controlling camera by Visca command

  • October 9, 2011
  • 1 reply
  • 1776 views

Hi guys,

I am writing a serial socket to send hex commands to a Sony Visca EVI_D70 PTZ camera.

The VISCA up-tilt command is as below:

8x 01 06 01 VV WW 03 01 FF

I tried socket.writeByte, socket.writeBytes and socket.writeMultiByte

My code, for example:

socket.writeBytes("8x 01 06 01 VV WW 03 01 FF")

Error messages appears:

1067: Implicit coercion of a value of type String to an unrelated type flash.utils:ByteArray.

Please tell me how to deliver hex commands.

Thanks a lot

Eddie

This topic has been closed for replies.

1 reply

October 9, 2011

The error is telling you that writeBytes wants a ByteArray, not a string. So you need something like:

var a:ByteArray = new ByteArray();

a.writeUTFBytes("8x 01 06 01 VV WW 03 01 FF");

socket.writeBytes(a);

October 9, 2011

Thanks a lot! You are helpful.

I tried the code immediately as below:

protected function doArcadeDown( event:MouseEvent ):void

  {

   //begin tilt_up

   var a:ByteArray = new ByteArray();

   a.writeUTFBytes("8x 01 06 01 VV WW 03 01 FF");

   socket.writeBytes(a)

  }

  protected function doArcadeUp( event:MouseEvent ):void

  {

   //end tilt_up

   var b:ByteArray = new ByteArray();

   b.writeUTFBytes("8x 01 06 01 VV WW 03 03 FF");

   socket.writeBytes(b)

  }

Below is the complier errors referring to the above bold text:

1046: Type was not found or was not a compile-time constant: ByteArray.

1180: Call to a possibly undefined method ByteArray.

Please advise. Thanks.

Eddie

October 9, 2011

import ByteArray...

import flash.utils.ByteArray;