unsigned int CameraVC0706::sendCommand(unsigned char cmd, unsigned char *args, unsigned int argc) { unsigned int sentBytes = 0; unsigned int bufSize = 4 + argc; unsigned char buf[bufSize]; buf[0] = VC0760_PROTOCOL_SIGN_TX; buf[1] = serialNumber; buf[2] = cmd; buf[3] = argc; memcpy(&buf[4], args, argc); printBuff(buf, bufSize); sentBytes = write(buf, bufSize); #if VC0760_DEBUG == 1 debug->print(sentBytes); debug->println(" bytes written."); #endif if (sentBytes != bufSize) { #if VC0760_DEBUG == 1 debug->print("Sent different amount than expected: "); debug->println(bufSize); #endif return 0; } return sentBytes; }
unsigned int CameraVC0706::readResponse(unsigned int length) { rxBufferPointer = read(rxBuffer, length); #if VC0760_DEBUG == 1 printBuff(rxBuffer, rxBufferPointer); #endif return rxBufferPointer; }
boolean camera_VC0706::getPTZ(uint16_t &w, uint16_t &h, uint16_t &wz, uint16_t &hz, uint16_t &pan, uint16_t &tilt) { uint8_t args[] = {0x0}; if (! runCommand(VC0706_GET_ZOOM, args, sizeof(args), 16)) return false; printBuff(); w = camerabuff[5]; w <<= 8; w |= camerabuff[6]; h = camerabuff[7]; h <<= 8; h |= camerabuff[8]; wz = camerabuff[9]; wz <<= 8; wz |= camerabuff[10]; hz = camerabuff[11]; hz <<= 8; hz |= camerabuff[12]; pan = camerabuff[13]; pan <<= 8; pan |= camerabuff[14]; tilt = camerabuff[15]; tilt <<= 8; tilt |= camerabuff[16]; return true; }
void camera_VC0706::OSD(uint8_t x, uint8_t y, char *str) { if (strlen(str) > 14) { str[13] = 0; } uint8_t args[17] = {strlen(str), strlen(str)-1, (y & 0xF) | ((x & 0x3) << 4)}; for (uint8_t i=0; i<strlen(str); i++) { char c = str[i]; if ((c >= '0') && (c <= '9')) { str[i] -= '0'; } else if ((c >= 'A') && (c <= 'Z')) { str[i] -= 'A'; str[i] += 10; } else if ((c >= 'a') && (c <= 'z')) { str[i] -= 'a'; str[i] += 36; } args[3+i] = str[i]; } runCommand(VC0706_OSD_ADD_CHAR, args, strlen(str)+3, 5); printBuff(); }
uint8_t VC0706::getCompression(void) { uint8_t args[] = { 0x4, 0x1, 0x1, 0x12, 0x04 }; runCommand(VC0706_READ_DATA, args, sizeof(args), 6); printBuff(); return camerabuff[5]; }
int main(){ timestamp_t t = 12345; std::cout<<"Input Number:"<<t<<std::endl; char* b = new char[4]; std::cout<<"virgin bf:";printBuff(b,4); tsToBuff(&t, b, 4); std::cout<<"tsToBuff :";printBuff(b,4); timestamp_t u = hton32(t); memcpy(b, &u, 4); std::cout<<"memcpy bs:";printBuff(b,4); // memcpy(b, &t, 4); // std::cout<<"memcpy :";printBuff(b,4); timestamp_t ts = buffToTs(b, 4); std::cout<<"buffToTs:"<<ts<<std::endl; memcpy(&ts, b, 4); std::cout<<"memcpy :"<<ts<<std::endl; std::cout<<"casting :"<<*((timestamp_t*)b)<<std::endl; }
void Editor::drawThread() { initializeTerminal(); int mode = getMode(); while(mode != EXIT) { //print status line first, since getch blocks updateStatus(); printBuff(_showPass); //blocks on input int input = getch(); handleInput(input); mode = getMode(); } //stop things and let object destruct refresh(); endwin(); }