//---------------------------------------------------------------------------- //Trägt Anwendung in Anwendungsliste ein void stack_init (void) { //Timer starten timer_init(); #if USE_PARAMETERS_FROM_EEPROM //IP, NETMASK und ROUTER_IP aus EEPROM auslesen (*((unsigned long*)&myip[0])) = para_getip(IP_EEPROM_STORE,MYIP); //MAC Adresse setzen if ( para_getchar(MAC_EEPROM_STORE) != 0xFF ) for ( int i=0; i<6; i++ ) mymac[i] = para_getchar(MAC_EEPROM_STORE+i); #else (*((unsigned long*)&myip[0])) = MYIP; #endif /*NIC Initialisieren*/ DEBUG_WRITE("\n\rNIC init:"); ETH_INIT(); DEBUG_WRITE("Ok\r\n"); #if USE_ENC28J60 ETH_PACKET_SEND(60,eth_buffer); ETH_PACKET_SEND(60,eth_buffer); #endif DEBUG_WRITE("My IP: %1i.%1i.%1i.%1i\r\n\r\n",myip[0],myip[1],myip[2],myip[3]); }
static void _list_grow(LIST *list){ DEBUG_WRITE(("_list_grow begin: [alloc_len]%d, [header]%p\n", list->alloc_len, list->header)); list->alloc_len *= 2; list->header = realloc(list->header, list->alloc_len * list->elem_size); assert(list->header != NULL); DEBUG_WRITE(("_list_grow end: [alloc_len]%d, [header]%p\n", list->alloc_len, list->header)); }
void stack_pop(STACK *stack, void *data){ DEBUG_WRITE(("stack_pop begin: [used_len]%d\n", stack->used_len)); assert(stack->used_len > 0); stack->used_len--; void *source = (char*)stack->header + stack->used_len * stack->elem_size; memcpy(data, source, stack->elem_size); DEBUG_WRITE(("stack_pop end: [used_len]%d\n", stack->used_len)); }
int main(int argc,char** argv){ CmdLine cmd(argc,argv); DEBUG_WRITE("Starting program"); vpDisplay* disp = new vpDisplayX(); vpVideoWriter writer; vpImage<vpRGBa> out_I,out_I_overlay; std::vector< vpImage<vpRGBa> > in_I; if(cmd.should_exit()) return 0; //exit if needed DEBUG_WRITE("initializing writer"); writer.setFileName((cmd.get_output_dir() + std::string("/%08d.jpg")).c_str()); writer.open(out_I); std::vector<boost::shared_ptr<VideoWithCaption> > videos = cmd.get_videos(); unsigned int cursor_x=0,cursor_y=0; DEBUG_WRITE("initializing images"); for(std::vector<boost::shared_ptr<VideoWithCaption> >::iterator i=videos.begin();i!=videos.end();i++){ if(cmd.get_debug()) std::cout << "initializing image from " << (*i)->caption << "(" << (*i)->path <<")"<< std::endl; (*i)->reader.acquire((*i)->I); (*i)->y=cursor_y; (*i)->x=cursor_x; cursor_x+=(*i)->I.getWidth(); if(cmd.get_debug()) std::cout << "configuring a new image at " << (*i)->x << "," << (*i)->y << std::endl; } out_I.resize(std::max(cursor_y,videos[0]->I.getHeight()),cursor_x); disp->init(out_I); if(cmd.get_debug()) std::cout << "Output image size set to " << out_I.getWidth() << "x" << out_I.getHeight() << std::endl; bool last_frame_reached=false; for(;!last_frame_reached;){ vpDisplay::display(out_I); for(std::vector<boost::shared_ptr<VideoWithCaption> >::iterator i=videos.begin();i!=videos.end();i++){ if((*i)->reader.getFrameIndex()-2>(*i)->reader.getLastFrameIndex()){ last_frame_reached=true; break; } out_I.insert((*i)->I,vpImagePoint((*i)->y,(*i)->x)); vpDisplay::displayCharString(out_I,vpImagePoint((*i)->y+CAPTION_OFFSET_X,(*i)->x+CAPTION_OFFSET_Y),(*i)->caption.c_str(),vpColor::blue); (*i)->reader.acquire((*i)->I); } vpDisplay::flush(out_I); vpDisplay::getImage(out_I,out_I_overlay); writer.saveFrame(out_I_overlay); writer.saveFrame(out_I_overlay); writer.saveFrame(out_I_overlay); } writer.close(); return 0; }
void list_new(LIST *list, int elem_size, void(*free_elem_fn)(void*)){ DEBUG_WRITE(("list_new begin: [elem_size]%d\n", elem_size)); assert(elem_size > 0); list->elem_size = elem_size; list->used_len = 0; list->alloc_len = INIT_ALLOC_LEN; list->free_elem_fn = free_elem_fn; list->header = malloc(INIT_ALLOC_LEN * elem_size); assert(list->header != NULL); DEBUG_WRITE(("list_new end\n")); }
void* list_add_elem(LIST *list, void *data){ DEBUG_WRITE(("list_add_elem begin: [used_len]%d\n", list->used_len)); assert(list->alloc_len >= list->used_len); if(list->alloc_len == list->used_len) _list_grow(list); void *target = (char*)list->header + list->used_len * list->elem_size; memcpy(target, data, list->elem_size); list->used_len++; DEBUG_WRITE(("list_add_elem end: [used_len]%d\n", list->used_len)); return target; }
void list_free(LIST *list){ DEBUG_WRITE(("list_free begin\n")); int i; if(list->free_elem_fn != NULL){ for(i = 0; i < list->used_len; i++){ DEBUG_WRITE(("list_free_sub begin: [idx]%d\n", i)); list->free_elem_fn((char*)list->header + i * list->elem_size); DEBUG_WRITE(("list_free_sub end: [idx]%d\n", i)); } } free(list->header); DEBUG_WRITE(("list_free end\n")); }
CmdLine::CmdLine(int argc,char**argv) : should_exit_(false) { po::options_description general("General options"); general.add_options() ("directories,d", po::value< std::vector<std::string> >(&dirs_),"directories to display on video") ("captions,c", po::value< std::vector<std::string> >(&captions_),"captions to display on videos (in the same order as directories)") ("output-directory,o", po::value<std::string>(&output_dir_),"output directory where the concatenated images are stored") ("verbose,v", "verbose mode") ("debug,D", "debug mode") ("help", "produce help message") ; prog_args.add(general); po::store(po::parse_command_line(argc, argv, prog_args), vm_); po::notify(vm_); if (vm_.count("help")) { std::cout << prog_args << std::endl; should_exit_ = true; } DEBUG_WRITE("Debug mode active."); unsigned int nbvid=0; std::string cur_caption(""); for(std::vector< std::string >::iterator i=dirs_.begin(), cap_iter=captions_.begin(); i!=dirs_.end(); i++,nbvid++){ if(cap_iter==captions_.end()) cur_caption = ""; else{ cur_caption = *cap_iter; cap_iter++; } boost::shared_ptr<VideoWithCaption> el(new VideoWithCaption()); el->caption=cur_caption; el->path = i->c_str(); el->reader.setFileName( i->c_str() ); el->reader.setFirstFrameIndex(0); el->reader.open(el->I); videos_.push_back(el); if(get_verbose()){ std::cout << "Adding video with path " << el->path << " and caption " << el->caption << std::endl; } } DEBUG_WRITE("Done adding videos."); if(get_verbose()) std::cout << nbvid << " videos added." << std::endl; }
extern "C" jboolean Java_org_ebookdroid_droids_djvu_codec_DjvuPage_renderPage(JNIEnv *env, jclass cls, jlong pageHangle, jint targetWidth, jint targetHeight, jfloat pageSliceX, jfloat pageSliceY, jfloat pageSliceWidth, jfloat pageSliceHeight, jintArray buffer, jint rendermode) { DEBUG_WRITE("Rendering page"); ddjvu_page_t* page = (ddjvu_page_t*) ((pageHangle)); ddjvu_rect_t pageRect; pageRect.x = 0; pageRect.y = 0; pageRect.w = targetWidth / pageSliceWidth; pageRect.h = targetHeight / pageSliceHeight; ddjvu_rect_t targetRect; targetRect.x = pageSliceX * targetWidth / pageSliceWidth; targetRect.y = pageSliceY * targetHeight / pageSliceHeight; targetRect.w = targetWidth; targetRect.h = targetHeight; unsigned int masks[] = { 0xFF0000, 0x00FF00, 0x0000FF }; ddjvu_format_t* pixelFormat = ddjvu_format_create(DDJVU_FORMAT_RGBMASK32, 3, masks); ddjvu_format_set_row_order(pixelFormat, TRUE); ddjvu_format_set_y_direction(pixelFormat, TRUE); char *pBuffer = (char *) env->GetPrimitiveArrayCritical(buffer, 0); jboolean result = ddjvu_page_render(page, (ddjvu_render_mode_t) rendermode, &pageRect, &targetRect, pixelFormat, targetWidth * 4, pBuffer); env->ReleasePrimitiveArrayCritical(buffer, pBuffer, 0); ddjvu_format_release(pixelFormat); return result; }
static void _destroy_train(void *data){ TRAIN *train = (TRAIN*)data; DEBUG_WRITE(("_destroy_train: [no]%s, [stations]%p, [size]%d\n", train->no, train->stations, train->stations->used_len)); list_free(train->stations); free(train->stations); }
//---------------------------------------------------------------------------- //Check Packet and call Stack for TCP or UDP void check_packet (void) { //Pointer auf Ethernet_Header struct Ethernet_Header *ethernet; ethernet = (struct Ethernet_Header *)ð_buffer[ETHER_OFFSET]; //Pointer auf IP_Header struct IP_Header *ip; ip = (struct IP_Header *)ð_buffer[IP_OFFSET]; #if USE_PING //Pointer auf ICMP_Header struct ICMP_Header *icmp; icmp = (struct ICMP_Header *)ð_buffer[ICMP_OFFSET]; #endif if(ETHERNET_ARP_DATAGRAMM) { //Erzeugt ein ARP Reply Packet arp_reply(); } else { if(ETHERNET_IP_DATAGRAMM && IF_MYIP) { arp_entry_add(); //Refresh des ARP Eintrages #if USE_PING //Ist protokoll Byte = 1 dann ist es ein ICMP Packet if(IP_ICMP_PACKET) { switch ( icmp->ICMP_Type ) { case (0x08): //Echo-Request empfangen, erzeugen eines ICMP Reply Packet (PING Echo) icmp_send(ip->IP_Srcaddr,0x00,0x00,icmp->ICMP_SeqNum,icmp->ICMP_Id); break; case (0x00): //Echo-Reply Packet empfangen, Empfang melden //TODO: Erst Sequenznummer vergleichen?, Zeitmessung? DEBUG_WRITE("%i",(ip->IP_Srcaddr&0x000000FF)); DEBUG_WRITE(".%i",((ip->IP_Srcaddr&0x0000FF00)>>8)); DEBUG_WRITE(".%i",((ip->IP_Srcaddr&0x00FF0000)>>16)); DEBUG_WRITE(".%i",((ip->IP_Srcaddr&0xFF000000)>>24)); DEBUG_WRITE(": PONG!\r\n"); break; } return; } else #endif { if(IP_UDP_PACKET) udp_socket_process(); } }
int HC05::cmd(const char* cmd, unsigned long timeout) { int recvd = 0; DEBUG_PRINTLN(cmd); setCmdPin(HIGH); // No spec for how long it takes to enter command mode, but 100ms // seems to work- assuming the output has been drained. delay(100); _btSerial.write(cmd); _btSerial.write("\r\n"); _btSerial.setTimeout(timeout); do { // ATTENTION: At least through Arduino v1.0.3, it is not possible // to tell the difference between a timeout and // receiving only the termination character (NL in this // case), because the termination character is not // returned and timeout is not returned as a unique // indication. // In this case the result would be an early return // of a multiline response before the OK is received. // The return would incorrectly indicate an error (no // OK response). recvd = _btSerial.readBytesUntil('\n',_buffer,_bufsize); if (recvd > 0) { DEBUG_WRITE((uint8_t *)_buffer,recvd); DEBUG_WRITE('\n'); } else { DEBUG_PRINTLN("timeout 1"); } } while ((recvd > 0) && (_buffer[0] != 'O' || _buffer[1] != 'K')); setCmdPin(LOW); // Empirically determined that it takes some time to reliably exit // command mode. The appeared to be a baud rate dependency and with // >100ms required at 9600 baud. delay(150); return((_buffer[0] == 'O' && _buffer[1] == 'K')); }
void list_load(LIST *list, FILE *fp, void(*load_elem_fn)(void*, FILE*), void(*free_elem_fn)(void*)){ assert(fp != NULL); DEBUG_WRITE(("list_load begin\n")); fread(list, sizeof(LIST), 1, fp); //LIST DEBUG_WRITE(("list_load [alloc_len]:%d, [used_len]:%d\n", list->alloc_len, list->used_len)); list->header = malloc(list->alloc_len * list->elem_size); list->free_elem_fn = free_elem_fn; int i; void *elem; for(i = 0; i<list->used_len; i++){ elem = list_get_elem_by_idx(list, i); DEBUG_WRITE(("list_load_elem begin: [idx]%d\n", i)); fread(elem, list->elem_size, 1, fp);//elem DEBUG_WRITE(("list_load_elem end: [idx]%d\n", i)); if(load_elem_fn != NULL){ //if elem is a pointer DEBUG_WRITE(("list_load_elem_ref begin: [idx]%d\n", i)); load_elem_fn(elem, fp); DEBUG_WRITE(("list_load_elem_ref begin: [idx]%d\n", i)); } } DEBUG_WRITE(("list_load end\n")); }
HistoryTable(std::ostream &os, size_t size, size_t maxVersionsCnt, RDMAContext &baseContext, int mrFlags) : os_(os), size_(size), maxVersionsCnt_(maxVersionsCnt){ headVersions = new RDMARegion<HistoryVersion>(size, baseContext, mrFlags); tsList = new RDMARegion<Timestamp>(size * maxVersionsCnt, baseContext, mrFlags); olderVersions = new RDMARegion<HistoryVersion>(size * maxVersionsCnt, baseContext, mrFlags); DEBUG_WRITE(os_, "HistoryTable", __func__, "[Info] History table initialized"); }
WarehouseTable(std::ostream &os, size_t size, size_t maxVersionsCnt, RDMAContext &baseContext, int mrFlags) : os_(os), size_(size), maxVersionsCnt_(maxVersionsCnt){ headVersions = new RDMARegion<WarehouseVersion>(size, baseContext, mrFlags); tsList = new RDMARegion<Timestamp>(size * maxVersionsCnt, baseContext, mrFlags); olderVersions = new RDMARegion<WarehouseVersion>(size * maxVersionsCnt, baseContext, mrFlags); DEBUG_WRITE(os_, "WarehouseTable", __func__, "[Info] Warehouse table initialized with " << size << " tuples"); }
void CallDocInfoCallback(JNIEnv* env, jobject thiz, const ddjvu_message_t* msg) { DEBUG_WRITE("Calling handleDocInfo callback"); jclass cls = env->GetObjectClass(thiz); if (!cls) return; jmethodID handleDocInfoId = env->GetMethodID(cls, "handleDocInfo", "()V"); if (!handleDocInfoId) return; env->CallVoidMethod(thiz, handleDocInfoId); }
void IntermediateValues::writeIV(uint32 mapID, uint32 tileX, uint32 tileY) { char fileName[255]; char tileString[25]; sprintf(tileString, "[%02u,%02u]: ", tileX, tileY); printf("%sWriting debug output... \r", tileString); std::string name("meshes/%03u%02i%02i."); #define DEBUG_WRITE(fileExtension,data) \ do { \ sprintf(fileName, (name + fileExtension).c_str(), mapID, tileY, tileX); \ FILE* file = fopen(fileName, "wb"); \ if (!file) \ { \ char message[1024]; \ sprintf(message, "%sFailed to open %s for writing!\n", tileString, fileName); \ perror(message); \ } \ else \ debugWrite(file, data); \ if (file) fclose(file); \ printf("%sWriting debug output... \r", tileString); \ } while (false) if (heightfield) DEBUG_WRITE("hf", heightfield); if (compactHeightfield) DEBUG_WRITE("chf", compactHeightfield); if (contours) DEBUG_WRITE("cs", contours); if (polyMesh) DEBUG_WRITE("pmesh", polyMesh); if (polyMeshDetail) DEBUG_WRITE("dmesh", polyMeshDetail); #undef DEBUG_WRITE }
/* * If setBaud() is called while the HC-05 is connected, then * it will be disconnected when AT+RESET command is issued, and * it may take 2 (or more?) connection attempts to reconnect. The extra * connect attempts may be a host side issue and not specific to the * HC-05 module. */ void HC05::setBaud(unsigned long baud, unsigned long stopbits, unsigned long parity) { int recvd = 0; setCmdPin(HIGH); delay(200); DEBUG_WRITE("AT+UART="); _btSerial.write("AT+UART="); DEBUG_PRINT(baud); _btSerial.print(baud); DEBUG_PRINT(","); _btSerial.print(","); DEBUG_PRINT(stopbits); _btSerial.print(stopbits); DEBUG_PRINT(","); _btSerial.print(","); DEBUG_PRINT(parity); _btSerial.print(parity); DEBUG_WRITE("\r\n"); _btSerial.write("\r\n"); recvd = _btSerial.readBytes(_buffer,_bufsize); if (recvd > 0) { DEBUG_WRITE((uint8_t *)_buffer,recvd); } else { DEBUG_PRINTLN("timeout 2"); } cmd("AT+RESET"); setCmdPin(LOW); _btSerial.begin(baud); delay(1000); }
unsigned long HC05::findBaud() { const int bt_rx = 4; const int bt_tx = 5; int numRates = sizeof(rates)/sizeof(unsigned long); int response = false; int recvd = 0; //char _buffer[128]; DEBUG_PRINTLN("findBaud"); setCmdPin(HIGH); delay(100); for(int rn = 0; rn < numRates; rn++) { _btSerial.begin(rates[rn]); _btSerial.setTimeout(100); _btSerial.flush(); DEBUG_WRITE("Trying "); DEBUG_PRINT(rates[rn]); DEBUG_WRITE("... "); _btSerial.write("AT\r\n"); recvd = _btSerial.readBytes(_buffer,_bufsize); if (recvd > 0) { DEBUG_PRINTLN("Found."); // FIXME: refactor to a single return setCmdPin(LOW); return(rates[rn]); } else { DEBUG_PRINTLN("x"); } } setCmdPin(LOW); DEBUG_WRITE("\r\nNo connection\r\n"); return(0); }
void list_save(LIST *list, FILE *fp, void(*save_elem_fn)(void*, FILE*)){ assert(fp != NULL); DEBUG_WRITE(("list_save begin\n")); fwrite(list, sizeof(LIST), 1, fp); //LIST int i; void *elem; for(i = 0; i<list->used_len; i++){ elem = list_get_elem_by_idx(list, i); DEBUG_WRITE(("list_save_elem begin: [idx]%d\n", i)); fwrite(elem, list->elem_size, 1, fp);//elem DEBUG_WRITE(("list_save_elem end: [idx]%d\n", i)); if(save_elem_fn != NULL){ //if elem is a pointer DEBUG_WRITE(("list_save_elem_ref begin: [idx]%d\n", i)); save_elem_fn(elem, fp); DEBUG_WRITE(("list_save_elem_ref begin: [idx]%d\n", i)); } } DEBUG_WRITE(("list_save end\n")); }
extern "C" jboolean Java_org_ebookdroid_droids_djvu_codec_DjvuPage_renderPageBitmap(JNIEnv *env, jclass cls, jlong pageHangle, jint targetWidth, jint targetHeight, jfloat pageSliceX, jfloat pageSliceY, jfloat pageSliceWidth, jfloat pageSliceHeight, jobject bitmap, jint rendermode) { //#ifdef USE_JNI_BITMAP_API DEBUG_WRITE("Rendering page bitmap"); AndroidBitmapInfo info; void *pixels; int ret; if ((ret = NativeBitmap_getInfo(env, bitmap, &info)) < 0) { DEBUG_PRINT("AndroidBitmap_getInfo() failed ! error=%d", ret); return 0; } DEBUG_WRITE("Checking format"); // if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) { // DEBUG_WRITE("Bitmap format is not RGBA_8888 !"); // return 0; // } if (info.format != ANDROID_BITMAP_FORMAT_RGB_565) { DEBUG_WRITE("Bitmap format is not RGB_565 !"); return 0; } DEBUG_WRITE("locking pixels"); if ((ret = NativeBitmap_lockPixels(env, bitmap, &pixels)) < 0) { DEBUG_PRINT("AndroidBitmap_lockPixels() failed ! error=%d", ret); return 0; } ddjvu_page_t* page = (ddjvu_page_t*) ((pageHangle)); ddjvu_rect_t pageRect; pageRect.x = 0; pageRect.y = 0; pageRect.w = targetWidth / pageSliceWidth; pageRect.h = targetHeight / pageSliceHeight; ddjvu_rect_t targetRect; targetRect.x = pageSliceX * targetWidth / pageSliceWidth; targetRect.y = pageSliceY * targetHeight / pageSliceHeight; targetRect.w = targetWidth; targetRect.h = targetHeight; unsigned int masks[] = { 0xF800, 0x07E0, 0x001F }; ddjvu_format_t* pixelFormat = ddjvu_format_create(DDJVU_FORMAT_RGBMASK16, 3, masks); // unsigned int masks[] = {0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000}; // ddjvu_format_t* pixelFormat = ddjvu_format_create(DDJVU_FORMAT_RGBMASK32, 4, masks); ddjvu_format_set_row_order(pixelFormat, TRUE); ddjvu_format_set_y_direction(pixelFormat, TRUE); // jboolean result = ddjvu_page_render(page, DDJVU_RENDER_COLOR, &pageRect, &targetRect, pixelFormat, targetWidth * 4, (char*)pixels); jboolean result = ddjvu_page_render(page, (ddjvu_render_mode_t) rendermode, &pageRect, &targetRect, pixelFormat, targetWidth * 2, (char*) pixels); ddjvu_format_release(pixelFormat); NativeBitmap_unlockPixels(env, bitmap); return result; //#else // DEBUG_WRITE("Rendering page bitmap not implemented"); // return 0; //#endif }
void* list_get_elem_by_idx(LIST *list, int idx){ DEBUG_WRITE(("list_get_elem_by_idx begin: [idx]%d\n", idx)); void *ret = (char*)list->header + list->elem_size * idx; DEBUG_WRITE(("list_get_elem_by_idx end: [idx]%d\n", idx)); return ret; }
~HistoryTable(){ DEBUG_WRITE(os_, "HistoryTable", __func__, "[Info] Deconstructor called"); delete headVersions; delete tsList; delete olderVersions; }