Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ViscaControl.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #ifndef WIN32
26 
27 #include <sys/time.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <sys/ioctl.h>
31 #include <fcntl.h>
32 #include <termios.h>
33 
34 #else
35 #include <windows.h>
36 #endif
37 
38 #include <iostream>
39 #include <sstream>
40 #include <stdio.h>
41 #include "ViscaControl.hh"
42 #include <Base/Common/W32Compat.hh>
43 
44 using namespace std;
45 using namespace BIAS;
46 
47 ViscaControl::
48 ViscaControl()
49 {
50  connected_ = false;
51  zoomed_ = false;
52  used_ = false;
53  maxZoom_ = 31424;
54  //maxZoom_ = 1023;
55 
56  // Set default pan and tilt speed for units without speed support.
57  // WARNING: Sending any other speed values to those units will
58  // result in an engine lock!
59  panSpeed_ = 0x18;
60  tiltSpeed_ = 0x1C;
61 
62  // Set default active unit
63  activeUnit_ = 0x81;
64 }
65 
66 ViscaControl::
67 ~ViscaControl()
68 {}
69 
70 bool ViscaControl::
71 InitPanTiltUnit(std::string port)
72 {
73  bool ret = false;
74 #ifdef BIAS_HAVE_PTHREADS
75  pthread_mutex_init(&camMutex,NULL);
76 #endif
77  //init pointers to the send and receive buffers
78  sendPtr=sendBuffer;
79 
80  //Windows: "\\\\.\\COM3"
81  cout<<"trying to open "<<port<<" for serial communication...";
82  ret = serialIO_.OpenPort(port);
83  if(!ret){ BIASERR("Could not open serial port!") return false; }
84  serialIO_.SetOptions(9600,SPPM_NoParity, false,false,false);
85  connected_ = true;
86 
87  // init the lens and start ccd pixel correction
88  CamInitialize_();
89  return true;
90 }
91 
92 bool ViscaControl::ClosePanTiltUnit()
93 {
94  // turn the camera off
95  bool ret = serialIO_.ClosePort();
96  connected_=false;
97 #ifdef BIAS_HAVE_PTHREADS
98  pthread_mutex_destroy(&camMutex);
99 #endif
100  return ret;
101 }
102 
103 
104 int ViscaControl::
105 SendCommand_(unsigned char* buf, int length,
106  bool manageAnswer)
107 {
108 
109  if(!connected_) return -1;
110 #ifdef BIAS_HAVE_PTHREADS
111  pthread_mutex_lock(&camMutex);
112 #endif
113  serialIO_.WriteBytes(buf,length);
114  if(manageAnswer)ManageAnswer();
115 #ifdef BIAS_HAVE_PTHREADS
116  pthread_mutex_unlock(&camMutex);
117 #endif
118  return 0;
119 }
120 
121 
122 void ViscaControl::ContinuousRead(){
123  while(true) {
124  biasmsleep(500);
125  ManageAnswer();
126  }
127 }
128 
129 void ViscaControl::ManageAnswer()
130 {
131  int length = 40;
132  //clear receiveBuffer to delete memory
133  unsigned char* receiveBuffer= new unsigned char[length];
134 
135  for (int i=0;i<length;i++){ receiveBuffer[i]=0; }
136 
137  cout<<"Reading answer as reply..";
138  int ret = serialIO_.ReadBytes(receiveBuffer,length,true);
139  if(ret < 0){BIASERR("Could not read answer")}
140  else cout<<"done, "<<ret<<" Bytes!"<<endl;
141 
142  cout<<"MSG:";
143  for (int i=0;i<ret;i++){
144  char temp[8];
145  sprintf(temp,"0x%02X, ", receiveBuffer[i]);
146  cout<<temp<<" ";
147  }
148  cout<<endl;
149 
150  if (receiveBuffer[0]==0x90 && receiveBuffer[1]==0x41 && receiveBuffer[2]==0xFF) {
151  cout << "ACK!" << endl;
152  }
153  if (receiveBuffer[1]==0x61)
154  {
155  if(receiveBuffer[2]==0x01){ BIASERR("Message length error.")}
156  else if(receiveBuffer[2]==0x02){ BIASERR("Syntax error.")}
157  else if(receiveBuffer[2]==0x03){ BIASERR("Command buffer full.")}
158  else if(receiveBuffer[2]==0x04){ BIASERR("Command cancelled.")}
159  else if(receiveBuffer[2]==0x05){ BIASERR("No socket (to be cancelled).")}
160  else if(receiveBuffer[2]==0x41){ BIASERR("Command not executable.")}
161  }
162  if(receiveBuffer[3]==0x90 && receiveBuffer[4]==0x51 && receiveBuffer[5]==0xFF) {
163  cout << "COMMAND COMPLETED!" << endl;
164  }
165  else{
166  cout<<"Uninterpreted reply:"<<endl;
167  }
168 
169  //Pt Position / ZOOM Inquiry Management:
170  //if ptpos was requested store it
171  //if zoompos was requested store it
172  if(receiveBuffer[0]==0x90 && receiveBuffer[1]==0x50){
173  if(!zoomed_){
174  pan_=0;
175  pan_|=(short)receiveBuffer[2]<<12;
176  pan_|=(short)receiveBuffer[3]<<8;
177  pan_|=(short)receiveBuffer[4]<<4;
178  pan_|=(short)receiveBuffer[5];
179  cout << "pan_ " << pan_ << endl;
180 
181  tilt_=0;
182  tilt_|=(short)receiveBuffer[6]<<12;
183  tilt_|=(short)receiveBuffer[7]<<8;
184  tilt_|=(short)receiveBuffer[8]<<4;
185  tilt_|=(short)receiveBuffer[9];
186  cout << "tilt_ " << tilt_ << endl;
187  used_ = false;
188  }
189  else {
190  //zoom pos was requested
191  zoom_=0;
192  zoom_|=(int)receiveBuffer[2]<<12;
193  zoom_|=(int)receiveBuffer[3]<<8;
194  zoom_|=(int)receiveBuffer[4]<<4;
195  zoom_|=(int)receiveBuffer[5];
196  cout << "zoom int " << zoom_ << endl;
197 
198  zoomed_ = false;
199  used_ = false;
200  }
201  }
202  delete[] receiveBuffer;
203 }
204 
205 
206 void ViscaControl::MoveRelative(short relPan, short relTilt)
207 {
208  sendBuffer[0] = activeUnit_;
209  sendBuffer[1] = 0x01;
210  sendBuffer[2] = 0x06;
211  sendBuffer[3] = 0x03;
212  sendBuffer[4] = panSpeed_;
213  sendBuffer[5] = tiltSpeed_;
214  sendBuffer[6] = (unsigned char)((relPan >> 12) & 0x0F);
215  sendBuffer[7] = (unsigned char)((relPan >> 8) & 0x0F);
216  sendBuffer[8] = (unsigned char)((relPan >> 4) & 0x0F);
217  sendBuffer[9] = (unsigned char)(relPan & 0x0F);
218  sendBuffer[10]= (unsigned char)((relTilt >> 12) & 0x0F);
219  sendBuffer[11]= (unsigned char)((relTilt >> 8) & 0x0F);
220  sendBuffer[12]= (unsigned char)((relTilt >> 4) & 0x0F);
221  sendBuffer[13]= (unsigned char)(relTilt & 0x0F);
222  sendBuffer[14]= 0xFF;
223 
224  this->SendCommand_(sendBuffer,15);
225 }
226 
227 void ViscaControl::MoveAbsolute(short panPos, short tiltPos)
228 {
229  sendBuffer[0] = activeUnit_;
230  sendBuffer[1] = 0x01;
231  sendBuffer[2] = 0x06;
232  sendBuffer[3] = 0x02;
233  sendBuffer[4] = panSpeed_;
234  sendBuffer[5] = tiltSpeed_;
235  sendBuffer[6] = (unsigned char)((panPos >> 12)& 0x0F);
236  sendBuffer[7] = (unsigned char)((panPos>> 8)& 0x0F);
237  sendBuffer[8] = (unsigned char)((panPos>> 4) & 0x0F);
238  sendBuffer[9] = (unsigned char)(panPos & 0x000F);
239  sendBuffer[10]= (unsigned char)((tiltPos >> 12)& 0x0F);
240  sendBuffer[11]= (unsigned char)((tiltPos >> 8)& 0x0F);
241  sendBuffer[12]= (unsigned char)((tiltPos >> 4)& 0x0F);
242  sendBuffer[13]= (unsigned char)(tiltPos & 0x0F);
243  sendBuffer[14]= 0xFF;
244 
245  this->SendCommand_(sendBuffer,15);
246 }
247 
248 void ViscaControl::MovePhysical(short panSteps, short tiltSteps)
249 {
250  sendBuffer[0] = activeUnit_;
251  sendBuffer[1] = 0x01;
252  sendBuffer[2] = 0x06;
253  sendBuffer[3] = 0x08;
254  sendBuffer[4] = panSpeed_;
255  sendBuffer[5] = tiltSpeed_;
256  sendBuffer[6] = (unsigned char)((panSteps >> 12)& 0x0F);
257  sendBuffer[7] = (unsigned char)((panSteps >> 8)& 0x0F);
258  sendBuffer[8] = (unsigned char)((panSteps >> 4)& 0x0F);
259  sendBuffer[9] = (unsigned char)(panSteps & 0x000F);
260  sendBuffer[10]= (unsigned char)((tiltSteps >> 12)& 0x0F);
261  sendBuffer[11]= (unsigned char)((tiltSteps >> 8)& 0x0F);
262  sendBuffer[12]= (unsigned char)((tiltSteps >> 4)& 0x0F);
263  sendBuffer[13]= (unsigned char)(tiltSteps & 0x0F);
264  sendBuffer[14]= 0xFF;
265 
266  this->SendCommand_(sendBuffer,15);
267 
268 }
269 
270 void ViscaControl::LightOn() {
271 
272  sendBuffer[0] = activeUnit_;
273  sendBuffer[1] = 0x01;
274  sendBuffer[2] = 0x04;
275  sendBuffer[3] = 0x02;
276  sendBuffer[4] = 0x03;
277  sendBuffer[5] = 0x02;
278  sendBuffer[6] = 0x01;
279  sendBuffer[7] = 0xFF;
280 
281  this->SendCommand_(sendBuffer, 8);
282 }
283 
284 
285 void ViscaControl::LightOff() {
286 
287  sendBuffer[0] = activeUnit_;
288  sendBuffer[1] = 0x01;
289  sendBuffer[2] = 0x04;
290  sendBuffer[3] = 0x02;
291  sendBuffer[4] = 0x03;
292  sendBuffer[5] = 0x03;
293  sendBuffer[6] = 0x01;
294  sendBuffer[7] = 0xFF;
295 
296  this->SendCommand_(sendBuffer, 8);
297 }
298 
299 
300 void ViscaControl::Wash() {
301 
302  sendBuffer[0] = activeUnit_;
303  sendBuffer[1] = 0x01;
304  sendBuffer[2] = 0x04;
305  sendBuffer[3] = 0x02;
306  sendBuffer[4] = 0x02;
307  sendBuffer[5] = 0x01; // Timer / On / Off
308  sendBuffer[6] = 0x01; // Set timer (seconds)
309  sendBuffer[7] = 0xFF;
310 
311  this->SendCommand_(sendBuffer, 8);
312 }
313 
314 
315 void ViscaControl::Wipe() {
316 
317  sendBuffer[0] = activeUnit_;
318  sendBuffer[1] = 0x01;
319  sendBuffer[2] = 0x05;
320  sendBuffer[3] = 0x06;
321  sendBuffer[4] = 0x01;
322  sendBuffer[5] = 0x01; // Intervals / On / Off
323  sendBuffer[6] = 0x01; // Set number of intervals
324  sendBuffer[7] = 0xFF;
325 
326  this->SendCommand_(sendBuffer, 8);
327 }
328 
329 
330 
331 void ViscaControl::CamPower(bool mode)
332 {
333  sendBuffer[0]= activeUnit_;
334  sendBuffer[1]= 0x01;
335  sendBuffer[2]= 0x04;
336  sendBuffer[3]= 0x00;
337 
338  if(mode) { sendBuffer[4]=0x02; } // POWER ON
339  else { sendBuffer[4]=0x03; } // POWER OFF
340 
341  sendBuffer[5]= 0xFF;
342 
343  this->SendCommand_(sendBuffer,6);
344 }
345 
346 int ViscaControl::CamInitialize_()
347 {
348  sendBuffer[0]= activeUnit_;
349  sendBuffer[1]= 0x01;
350  sendBuffer[2]= 0x04;
351  sendBuffer[3]= 0x19;
352  sendBuffer[4]= 0x01; // Lens Initialisation Start
353  sendBuffer[5]= 0xFF;
354 
355  this->SendCommand_(sendBuffer,6);
356 
357  sendBuffer[4]=0x02; // Correction of CCD pixel blemishes
358 
359  return SendCommand_(sendBuffer,6);
360 }
361 
362 void ViscaControl::PanTiltPosInq()
363 {
364  sendBuffer[0]= activeUnit_; //PANTILTPHYPOSING
365  sendBuffer[1]= 0x09;
366  sendBuffer[2]= 0x06;
367  sendBuffer[3]= 0x12; //0x15 fuer PTPhy
368  sendBuffer[4]= 0xFF;
369  this->SendCommand_(sendBuffer,5);
370 }
371 
372 void ViscaControl::MoveHome()
373 {
374  sendBuffer[0]= activeUnit_;
375  sendBuffer[1]= 0x01;
376  sendBuffer[2]= 0x06;
377  sendBuffer[3]= 0x04;
378  sendBuffer[4]= 0xFF;
379  this->SendCommand_(sendBuffer,5);
380 }
381 
382 
383 void ViscaControl::AdressSet()
384 {
385  sendBuffer[0]= activeUnit_;
386  sendBuffer[1]= 0x30;
387  sendBuffer[2]= 0x01;
388  sendBuffer[3]= 0xFF;
389 
390  this->SendCommand_(sendBuffer,4);
391 }
392 
393 void ViscaControl::MoveLeft()
394 {
395  sendBuffer[0]= activeUnit_;
396  sendBuffer[1]= 0x01;
397  sendBuffer[2]= 0x06;
398  sendBuffer[3]= 0x01;
399  sendBuffer[4]= panSpeed_;
400  sendBuffer[5]= tiltSpeed_;
401  sendBuffer[6]= 0x01;
402  sendBuffer[7]= 0x03;
403  sendBuffer[8]= 0xFF;
404 
405  this->SendCommand_(sendBuffer,9);
406 }
407 
408 void ViscaControl::MoveRight()
409 {
410  sendBuffer[0]= activeUnit_;
411  sendBuffer[1]= 0x01;
412  sendBuffer[2]= 0x06;
413  sendBuffer[3]= 0x01;
414  sendBuffer[4]= panSpeed_;
415  sendBuffer[5]= tiltSpeed_;
416  sendBuffer[6]= 0x02;
417  sendBuffer[7]= 0x03;
418  sendBuffer[8]= 0xFF;
419 
420  this->SendCommand_(sendBuffer,9);
421 }
422 void ViscaControl::MoveUp()
423 {
424  sendBuffer[0]= activeUnit_;
425  sendBuffer[1]= 0x01;
426  sendBuffer[2]= 0x06;
427  sendBuffer[3]= 0x01;
428  sendBuffer[4]= panSpeed_;
429  sendBuffer[5]= tiltSpeed_;
430  sendBuffer[6]= 0x03;
431  sendBuffer[7]= 0x01;
432  sendBuffer[8]= 0xFF;
433  this->SendCommand_(sendBuffer,9);
434 }
435 
436 void ViscaControl::MoveUpLeft()
437 {
438  sendBuffer[0]= activeUnit_;
439  sendBuffer[1]= 0x01;
440  sendBuffer[2]= 0x06;
441  sendBuffer[3]= 0x01;
442  sendBuffer[4]= panSpeed_;
443  sendBuffer[5]= tiltSpeed_;
444  sendBuffer[6]= 0x01;
445  sendBuffer[7]= 0x01;
446  sendBuffer[8]= 0xFF;
447 
448  this->SendCommand_(sendBuffer,9);
449 }
450 
451 void ViscaControl::MoveUpRight()
452 {
453  sendBuffer[0]= activeUnit_;
454  sendBuffer[1]= 0x01;
455  sendBuffer[2]= 0x06;
456  sendBuffer[3]= 0x01;
457  sendBuffer[4]= panSpeed_;
458  sendBuffer[5]= tiltSpeed_;
459  sendBuffer[6]= 0x02;
460  sendBuffer[7]= 0x01;
461  sendBuffer[8]= 0xFF;
462 
463  this->SendCommand_(sendBuffer,9);
464 }
465 
466 void ViscaControl::MoveDown()
467 {
468  sendBuffer[0]= activeUnit_;
469  sendBuffer[1]= 0x01;
470  sendBuffer[2]= 0x06;
471  sendBuffer[3]= 0x01;
472  sendBuffer[4]= panSpeed_;
473  sendBuffer[5]= tiltSpeed_;
474  sendBuffer[6]= 0x03;
475  sendBuffer[7]= 0x02;
476  sendBuffer[8]= 0xFF;
477 
478  this->SendCommand_(sendBuffer,9);
479 }
480 
481 void ViscaControl::MoveDownLeft()
482 {
483  sendBuffer[0]= activeUnit_;
484  sendBuffer[1]= 0x01;
485  sendBuffer[2]= 0x06;
486  sendBuffer[3]= 0x01;
487  sendBuffer[4]= panSpeed_;
488  sendBuffer[5]= tiltSpeed_;
489  sendBuffer[6]= 0x01;
490  sendBuffer[7]= 0x02;
491  sendBuffer[8]= 0xFF;
492 
493  this->SendCommand_(sendBuffer,9);
494 }
495 
496 void ViscaControl::MoveDownRight()
497 {
498  sendBuffer[0]= activeUnit_;
499  sendBuffer[1]= 0x01;
500  sendBuffer[2]= 0x06;
501  sendBuffer[3]= 0x01;
502  sendBuffer[4]= panSpeed_;
503  sendBuffer[5]= tiltSpeed_;
504  sendBuffer[6]= 0x02;
505  sendBuffer[7]= 0x02;
506  sendBuffer[8]= 0xFF;
507 
508  this->SendCommand_(sendBuffer,9);
509 }
510 
511 void ViscaControl::MoveStop()
512 {
513  sendBuffer[0]= activeUnit_;
514  sendBuffer[1]= 0x01;
515  sendBuffer[2]= 0x06;
516  sendBuffer[3]= 0x01;
517  sendBuffer[4]= panSpeed_;
518  sendBuffer[5]= tiltSpeed_;
519  sendBuffer[6]= 0x03;
520  sendBuffer[7]= 0x03;
521  sendBuffer[8]= 0xFF;
522 
523  this->SendCommand_(sendBuffer,9);
524 }
525 
526 
527 void ViscaControl::ZoomTele()
528 {
529  sendBuffer[0]= activeUnit_;
530  sendBuffer[1]= 0x01;
531  sendBuffer[2]= 0x04;
532  sendBuffer[3]= 0x07;
533  sendBuffer[4]= 0x02;
534  sendBuffer[5]= 0xFF;
535 
536  this->SendCommand_(sendBuffer,6);
537 
538  ZoomInq();
539 }
540 
541 void ViscaControl::ZoomWide()
542 {
543  sendBuffer[0]= activeUnit_;
544  sendBuffer[1]= 0x01;
545  sendBuffer[2]= 0x04;
546  sendBuffer[3]= 0x07;
547  sendBuffer[4]= 0x03;
548  sendBuffer[5]= 0xFF;
549 
550  this->SendCommand_(sendBuffer,6);
551 }
552 
553 void ViscaControl::ZoomStop()
554 {
555  sendBuffer[0]= activeUnit_;
556  sendBuffer[1]= 0x01;
557  sendBuffer[2]= 0x04;
558  sendBuffer[3]= 0x07;
559  sendBuffer[4]= 0x00;
560  sendBuffer[5]= 0xFF;
561 
562  zoomed_ = true;
563 
564  this->SendCommand_(sendBuffer,6);
565 }
566 
567 void ViscaControl::ResetPanTilt()
568 {
569  sendBuffer[0]= activeUnit_;
570  sendBuffer[1]= 0x01;
571  sendBuffer[2]= 0x06;
572  sendBuffer[3]= 0x05;
573  sendBuffer[4]= 0xFF;
574 
575  this->SendCommand_(sendBuffer,5);
576 }
577 
578 void ViscaControl::ResetCamCustom()
579 {
580  sendBuffer[0]= activeUnit_;
581  sendBuffer[1]= 0x01;
582  sendBuffer[2]= 0x04;
583  sendBuffer[3]= 0x3F;
584  sendBuffer[4]= 0x00;
585  sendBuffer[5]= 0x7F;
586  sendBuffer[6]= 0xFF;
587 
588  this->SendCommand_(sendBuffer,7);
589 }
590 
591 void ViscaControl::ZoomInq()
592 {
593  sendBuffer[0]= activeUnit_;
594  sendBuffer[1]= 0x09;
595  sendBuffer[2]= 0x04;
596  sendBuffer[3]= 0x47;
597  sendBuffer[4]= 0xFF;
598 
599  zoomed_=true;
600 
601  this->SendCommand_(sendBuffer,5);
602 }
603 
604 
605 void ViscaControl::ZoomDirect(short zoom)
606 {
607  if(zoom>maxZoom_){
608  zoom=(short)maxZoom_;
609  }
610  if(zoom<0){
611  zoom=0;
612  }
613 
614  cout<<"Zoom:"<<zoom<<endl;
615  sendBuffer[0]= activeUnit_;
616  sendBuffer[1]= 0x01;
617  sendBuffer[2]= 0x04;
618  sendBuffer[3]= 0x47;
619 
620  sendBuffer[4]= (unsigned char)((zoom >> 12)& 0x0F);
621  sendBuffer[5]= (unsigned char)((zoom >> 8)& 0x0F);
622  sendBuffer[6]= (unsigned char)((zoom >> 4)& 0x0F);
623  sendBuffer[7]= (unsigned char)(zoom & 0x0F);
624 
625  sendBuffer[8]= 0xFF;
626 
627  this->SendCommand_(sendBuffer,9);
628 }
629 
630 
631 
632 bool ViscaControl::SetCCDScanningMode(VISCA_CONSTANT mode){
633  //register 72, mode 0=interlaced, 1=progresive
634  sendBuffer[0]= activeUnit_;
635  sendBuffer[1]= 0x01;
636  sendBuffer[2]= 0x04;
637  sendBuffer[3]= 0x24;
638  sendBuffer[4]= 0x72;
639  sendBuffer[5]= 0x00;
640 
641  if(mode == VISCA_INTERLACED){
642  sendBuffer[6]= 0x00;
643  }
644  else if(mode == VISCA_PROGRESSIVE){
645  sendBuffer[6]= 0x01;
646  }
647 
648  sendBuffer[7]= 0xFF;
649  return this->SendCommand_(sendBuffer,8) != 0;
650 }
651 
652 ViscaControl::VISCA_CONSTANT ViscaControl::GetCCDScanningMode(){
653  sendBuffer[0]= activeUnit_;
654  sendBuffer[1]= 0x09;
655  sendBuffer[2]= 0x04;
656  sendBuffer[3]= 0x24;
657  sendBuffer[4]= 0x72;
658  sendBuffer[5]= 0xFF;
659  this->SendCommand_(sendBuffer,6,false);
661  int length = 20;
662  unsigned char* receiveBuffer= new unsigned char[length];
663  for (int i=0;i<length;i++) receiveBuffer[i]=0;
664 
665  bool ret = serialIO_.ReadBytes(receiveBuffer,length,true) != 0;
666  if(!ret)BIASERR("Could not read answer");
667 
668  if (receiveBuffer[2]==0x00 && receiveBuffer[3]==0x00) {
669  result= VISCA_INTERLACED;
670  }
671  else if(receiveBuffer[2]==0x00 && receiveBuffer[3]==0x01) {
672  result= VISCA_PROGRESSIVE;
673  }
674  else{
675  BIASERR("Unknown CCD Scanning Mode!");
676  result= VISCA_ERROR;
677  }
678  delete[] receiveBuffer;
679  return result;
680 }
681 
682 
683 
684 
685