static int show_btb_reg(int j, pfm_ita2_reg_t reg) { int ret; int is_valid = reg.pmd8_15_ita2_reg.btb_b == 0 && reg.pmd8_15_ita2_reg.btb_mp == 0 ? 0 :1; ret = safe_printf("\tPMD%-2d: 0x%016lx b=%d mp=%d valid=%c\n", j, reg.reg_val, reg.pmd8_15_ita2_reg.btb_b, reg.pmd8_15_ita2_reg.btb_mp, is_valid ? 'Y' : 'N'); if (!is_valid) return ret; if (reg.pmd8_15_ita2_reg.btb_b) { unsigned long addr; addr = reg.pmd8_15_ita2_reg.btb_addr<<4; addr |= reg.pmd8_15_ita2_reg.btb_slot < 3 ? reg.pmd8_15_ita2_reg.btb_slot : 0; ret = safe_printf("\t Source Address: 0x%016lx\n" "\t Taken=%c Prediction: %s\n\n", addr, reg.pmd8_15_ita2_reg.btb_slot < 3 ? 'Y' : 'N', reg.pmd8_15_ita2_reg.btb_mp ? "Failure" : "Success"); } else { ret = safe_printf("\t Target Address: 0x%016lx\n\n", ((unsigned long)reg.pmd8_15_ita2_reg.btb_addr<<4)); } return ret; }
/* * sigchld_handler - The kernel sends a SIGCHLD to the shell whenever * a child job terminates (becomes a zombie), or stops because it * received a SIGSTOP or SIGTSTP signal. The handler reaps all * available zombie children, but doesn't wait for any other * currently running children to terminate. */ void sigchld_handler(int sig) { // Save current errno value int tempErrNo = errno; int status = 0; pid_t pid; if ((pid = waitpid(-1, &status, WNOHANG|WUNTRACED)) > 0) { if (WIFEXITED(status)) { deletejob(jobs, pid); } else if (WIFSIGNALED(status)) { // Get the terminated job struct job_t* myJob = getjobpid(jobs, pid); // Print info on therminated job safe_printf("Job [%d] (%d) terminated by signal %d\n", myJob->jid, myJob->pid, WTERMSIG(status)); deletejob(jobs, pid); } else if (WIFSTOPPED(status)) { // Get the stopped job struct job_t* myJob = getjobpid(jobs, pid); // Change the state to stopped myJob->state = ST; // Print info on stopped job safe_printf("Job [%d] (%d) stopped by signal %d\n", myJob->jid, myJob->pid, WSTOPSIG(status)); } } else { if (errno != 0) { unix_error("Waitpid error"); } } // Restore errno value errno = tempErrNo; return; }
/* * sigchld_handler - The kernel sends a SIGCHLD to the shell whenever * a child job terminates (becomes a zombie), or stops because it * received a SIGSTOP, SIGTSTP, SIGTTIN or SIGTTOU signal. The * handler reaps all available zombie children, but doesn't wait * for any other currently running children to terminate. */ void sigchld_handler(int sig) { pid_t pid; int status; struct job_t *job; int old_err = errno; while((pid = waitpid(-1, &status, WNOHANG|WUNTRACED)) > 0 ) { if(WIFSTOPPED(status)) { job = getjobpid(job_list, pid); //Assume that pointer job is not NULL safe_printf("Job [%d] (%d) stopped by signal %d\n", job->jid, job->pid, WSTOPSIG(status)); job->state = ST; } else if(WIFSIGNALED(status)) { safe_printf("Job [%d] (%d) terminated by signal %d\n", pid2jid(pid), pid, WTERMSIG(status)); deletejob(job_list,pid); } else if(WIFEXITED(status)) deletejob(job_list,pid); } if( pid < 0 && errno != ECHILD && errno != EINTR ) { safe_printf("waitpid error: %s\n", strerror(errno)); _exit(1); } errno = old_err; return; }
int tst_getcmd(struct proc *proc, struct user *u) { char **arg; char **env; int i; char **p; struct pid pidbuf; if (kvm_kread(cookie, (uintptr_t)proc->p_pidp, &pidbuf, sizeof (pidbuf)) != sizeof (pidbuf)) { printf("ERROR: couldn't get pid\n"); return (-1); } printf("kvm_getcmd(pid:%d, [u], arg, env)\n", pidbuf.pid_id); if ((i = kvm_getcmd(cookie, proc, u, &arg, &env)) != 0) { printf("kvm_getcmd returned %d\n", i); return (i); } printf("Args: "); for (p = arg; *p != NULL; p++) safe_printf(*p); printf("Env: "); for (p = env; *p != NULL; p++) safe_printf(*p); (void) free(arg); (void) free(env); return (0); }
// // TODO: Include your function header here // static void sig_handler(int sig) { switch(sig) { case SIGINT: // treat interrupt safe_printf("\n[%d] Server terminated due to keyboard interrupt\n", getpid()); server_running = false; break; case SIGCHLD: // treat child process signal safe_printf("\n[%d] Signal from child process detected\n", getpid()); break; case SIGSEGV: // treat segfault safe_printf("\n[%d] Server terminated due to segmentation violation\n", getpid()); server_running = false; break; case SIGABRT: // treat abort safe_printf("\n[%d] Server terminated due to system abort\n", getpid()); server_running = false; break; default: break; } /* end switch */ } /* end of sig_handler */
static void name_column_print(LHAFileHeader *header) { if (header->path != NULL) { safe_printf("%s", header->path); } if (header->filename != NULL) { safe_printf("%s", header->filename); } if (header->symlink_target != NULL) { safe_printf(" -> %s", header->symlink_target); } }
static void suppress_most_common_pixel_hack(Mat&z,Rect handBB) { // hack, remove the most common pixel std::map<float,double> counts; Rect imBB(Point(0,0),z.size()); for(int yIter = 0; yIter < z.rows; ++yIter) for(int xIter = 0; xIter < z.cols; ++xIter) if(!handBB.contains(Point(xIter,yIter))) { float zz = z.at<float>(yIter,xIter); if(goodNumber(zz) && params::MIN_Z() <= zz && zz <= params::MAX_Z()) counts[zz] ++; } // find the larget count float common_z, common_zs_count = -inf; for(auto & pair : counts) if(pair.second > common_zs_count) { common_z = pair.first; common_zs_count = pair.second; } log_once(safe_printf("note: suppressing % %",common_z,common_zs_count)); // suppress! for(int yIter = 0; yIter < z.rows; ++yIter) for(int xIter = 0; xIter < z.cols; ++xIter) if(!handBB.contains(Point(xIter,yIter))) { float&zz = z.at<float>(yIter,xIter); if(zz == common_z) zz = inf; } }
static Mat load_semantics(string filename) { int id = getId(filename); Mat semantics_image; auto load_semantics = [&](string extension) -> bool { string sem_im_filename = boost::filesystem::path(filename).parent_path().string() + printfpp("/semantics%d.%s",id,extension.c_str()); semantics_image = imread(sem_im_filename,CV_LOAD_IMAGE_COLOR); if(semantics_image.empty()) { log_file << "Failed to load semantics_image: " << sem_im_filename << endl; return false; } for(int yIter = 0; yIter < semantics_image.rows; ++yIter) for(int xIter = 0; xIter < semantics_image.cols; ++xIter) { Vec3b&pixel = semantics_image.at<Vec3b>(yIter,xIter); pixel = HandRegion::quantize(pixel); } log_file << safe_printf("(info) loaded semantics image of size = ",semantics_image.size()) << endl; return true; }; assert(load_semantics("png") or load_semantics("jpg")); return semantics_image; }
DynVolNN::DynVolNN() : min_z(inf), max_z(-inf) { // load the training set ifstream notes("data/zball_big/notes.txt"); while(notes) { string filename; notes >> filename; float z_min; notes >> z_min; float z_max; notes >> z_max; Mat T = read_depth_mm(safe_printf("data/zball_big/%",filename)); if(T.empty()) { log_file << "warning " << filename << " was empty" << endl; continue; } T = imclamp(T,z_min,z_max); log_im_decay_freq("Template",[&](){return eq(T);}); templates.push_back(DynVolTempl{T,z_min,z_max}); min_z = std::min(min_z,z_min); max_z = std::max(max_z,z_max); } // }
void log_search_tree(SearchTree&tree_root) { if(not g_params.option_is_set("NN_LOG_TREE")) return; // for calcing the branching factor int internal_nodes = 0; int internal_node_children = 0; function<void (SearchTree&,string)> expandFn = [&](SearchTree&node,string prefix) -> void { Mat RGB = imageeq("",node.Templ.getTIm(),false,false); string filename = string("bound") + uuid() + ".jpg"; imwrite(prefix + "/" + filename,RGB); if(node.children.size() > 0) { internal_nodes++; internal_node_children += node.children.size(); } for(auto & child : node.children) { string new_dir = printfpp("%s/%d",prefix.c_str(),child->id); assert(boost::filesystem::create_directory(new_dir)); expandFn(*child,new_dir); } }; // traverse the tree. expandFn(tree_root,params::out_dir()); double mean_branching_factor = static_cast<double>(internal_node_children)/internal_nodes; log_once(safe_printf("mean_branching_factor = %",mean_branching_factor)); }
int report_error( char *reason, unsigned char *codes ) { status_error( codes ); print_mutex_lock(); safe_printf(("%s\r\n", reason)); print_mutex_unlock(); return 0; }
void log(string prefix,SphericalOccupancyMap&SOM) { Mat vis_r, vis_t, vis_z, vis_match,message,vis_raw_z; Mat zSlice = imclamp(SOM.get_OM(),t.z_min,t.z_max); // vis vis_raw_z = eq(SOM.get_OM()); vis_r = eq(r); vis_t = eq(t.t); vis_z = eq(zSlice); Mat vis_t_full(vis_z.rows,vis_z.cols,DataType<Vec3b>::type,Scalar::all(255)); { Mat src_roi = imroi(vis_t,Rect(Point(0,0),bb.size())); Mat dst_roi = imroi(vis_t_full,bb); src_roi.copyTo(dst_roi); } vis_match = im_merge( imroi(vis_r,Rect(Point(0,0),vis_z.size())), vis_z, vis_t_full); cv::rectangle(vis_match,bb.tl(),bb.br(),toScalar(BLUE)); message = image_text(safe_printf("resp = %",extrema(r).max)); vector<Mat> vs{vis_r,vis_t,vis_z,vis_match,vis_raw_z,message}; log_im(prefix,tileCat(vs)); }
void sigchld_handler (int sig){ pid_t pid; int status; while((pid = waitpid(-1, &status, WNOHANG|WUNTRACED)) > 0) { if(WIFSTOPPED(status)) { safe_printf("Job [%d] (%d) stopped by signal %d\n", pid2jid(pid), pid, WSTOPSIG(status)); changestate(job_list, pid, ST); } else { if(WIFSIGNALED(status)) { safe_printf("Job [%d] (%d) terminated by signal %d\n", pid2jid(pid), pid, WTERMSIG(status)); } deletejob(job_list, pid); } } return; }
void main() { int i = 123; float f = 3.14f; std::complex<double> c{1.1, 2.2}; std::cout << "int = " << i << ", float = " << f << ", complex = " << c << '\n'; // A noter qu'on n'a pas besoin de préciser les types // dans la chaîne de formatage car le compilateur les connaît! safe_printf("int = %, float = %, complex = %\n", i, f, c); }
/** * Dump all useful registers to the console * * @param registers CPU register to dump */ static void cvmx_interrupt_dump_registers(uint64_t registers[32]) { static const char *name[32] = {"r0","at","v0","v1","a0","a1","a2","a3", "t0","t1","t2","t3","t4","t5","t6","t7","s0","s1","s2","s3","s4","s5", "s6","s7", "t8","t9", "k0","k1","gp","sp","s8","ra"}; uint64_t reg; for (reg=0; reg<16; reg++) { safe_printf("%3s ($%02ld): 0x%016lx \t %3s ($%02ld): 0x%016lx\n", name[reg], reg, registers[reg], name[reg+16], reg+16, registers[reg+16]); } READ_COP0(reg, COP0_CAUSE); safe_printf("%16s: 0x%016lx\n", "COP0_CAUSE", reg); READ_COP0(reg, COP0_STATUS); safe_printf("%16s: 0x%016lx\n", "COP0_STATUS", reg); READ_COP0(reg, COP0_BADVADDR); safe_printf("%16s: 0x%016lx\n", "COP0_BADVADDR", reg); READ_COP0(reg, COP0_EPC); safe_printf("%16s: 0x%016lx\n", "COP0_EPC", reg); }
static void whole_line_name_column_print(LHAFileHeader *header) { if (header->path != NULL) { safe_printf("%s", header->path); } if (header->filename != NULL) { safe_printf("%s", header->filename); } // For wide filename mode (-v), | is used as the symlink separator, // instead of ->. The reason is that this is how symlinks are // represented within the file headers - the Unix LHA tool only // does the parsing in normal list mode. if (header->symlink_target != NULL) { safe_printf("|%s", header->symlink_target); } printf("\n"); }
void LibHandMetadata::log_metric_bb() const { // draw the metric bb Mat metric_viz = imageeq("",Z.clone(),false,false); Point bl(handBB.tl().x,handBB.br().y); Point tr(handBB.br().x,handBB.tl().y); cv::line(metric_viz,handBB.tl(),bl,toScalar(RED)); cv::line(metric_viz,handBB.br(),bl,toScalar(GREEN)); // compute edge lengths using law of cosines double z = medianApx(Z,handBB,.5); double t1 = camera.distance_angular(handBB.tl(),bl); double d1 = camera.distance_geodesic(handBB.tl(),z,bl,z); double t2 = camera.distance_angular(handBB.br(),bl); double d2 = camera.distance_geodesic(handBB.br(),z,bl,z); Mat text = vertCat(image_text(safe_printf("% cm % rad",d1,t1),RED), image_text(safe_printf("% cm % rad",d2,t2),GREEN)); text = vertCat(text,image_text(safe_printf("% cm",z))); log_im("MetricBBSides",vertCat(metric_viz,text)); }
void DynVolNN::log_times() const { lock_guard<mutex> l(monitor); for(auto && pair : performance_times) { int z = pair.first; double mean_time = performance_times.at(z) / performance_counts.at(z); log_file << safe_printf("z[%,%] = % / % = % ms", 50*z+min_z,50*(z+1)+min_z, performance_times.at(z),performance_counts.at(z), mean_time) << endl; } }
/* * sigchld_handler - The kernel sends a SIGCHLD to the shell whenever * a child job terminates (becomes a zombie), or stops because it * received a SIGSTOP or SIGTSTP signal. The handler reaps all * available zombie children, but doesn't wait for any other * currently running children to terminate. */ void sigchld_handler(int sig) { pid_t pid; int status; // SIGINT and SIGTSTP both read while ((pid = waitpid(-1,&status,WUNTRACED|WNOHANG)) > 0){ if (WIFSTOPPED(status)){ safe_printf("Job [%d] (%d) stopped by signal %d\n",pid2jid(pid),pid, WSTOPSIG(status)); struct job_t* job = getjobpid(jobs, pid); job->state = 3; }else if (WIFSIGNALED(status)){ safe_printf("Job [%d] (%d) terminated by signal %d\n",pid2jid(pid),pid, WTERMSIG(status)); deletejob(jobs, pid); }else if(WIFEXITED(status)){ deletejob(jobs, pid); }else{ safe_printf("child exited abnormally\n"); } } return; }
// // TODO: Include your function header here // static void sig_handler(int sig) { switch(sig) { case SIGINT: // use our own thread-safe implemention of printf safe_printf("\n[%d] Server terminated due to keyboard interrupt\n", getpid()); server_running = false; break; // TODO: Complete signal handler default: break; } /* end switch */ } /* end of sig_handler */
void safe_printf(const char *format, First first, Rest... rest) { for (; *format != '\0'; ++format) { if (*format == '%') { // Le type de l'argument 'first' est connu du compilateur; il s'agit donc d'une surcharge classique. std::cout << first; // appel "récursif" au template (avec un paramètre/argument de moins), // ou au cas terminal si 'rest...' est vide safe_printf(format + 1, rest...); // Après l'appel récursif, tout a été traité, il faut sortir directement. return; } std::cout << *format; } }
/* * sigtstp_handler - The kernel sends a SIGTSTP to the shell whenever * the user types ctrl-z at the keyboard. Catch it and suspend the * foreground job by sending it a SIGTSTP. */ void sigtstp_handler(int sig) { sigset_t mask; sigemptyset(&mask); sigaddset(&mask, SIGCHLD); sigprocmask(SIG_BLOCK, &mask, NULL); pid_t pid = fgpid(jobs); //we block SIGCHLD here for the same reason as the other handler if(pid){ if(kill(-pid,SIGTSTP)< 0){ safe_printf("Could not stop process\n"); } } sigprocmask(SIG_UNBLOCK, &mask, NULL); return; }
map< string, AnnotationBoundingBox > Metadata_Simple::get_positives() { map<string,AnnotationBoundingBox> implicit_abbs = MetaData::get_essential_positives(HandBB_RGB); for(auto && pair : explicit_abbs) { auto found = implicit_abbs.find(pair.first); if(found == implicit_abbs.end() or static_cast<Rect_<double>>(found->second) == Rect_<double>()) { implicit_abbs[pair.first] = pair.second; } else { implicit_abbs[pair.first] = pair.second; log_once(safe_printf("Metadata_Simple::get_positives % overwrite for part %",filename,pair.first)); } } return implicit_abbs; }
/* * sigint_handler - The kernel sends a SIGINT to the shell whenver the * user types ctrl-c at the keyboard. Catch it and send it along * to the foreground job. */ void sigint_handler(int sig) { sigset_t mask; sigemptyset(&mask); sigaddset(&mask, SIGCHLD); sigprocmask(SIG_BLOCK, &mask, NULL); pid_t pid = fgpid(jobs); //SIGCHLD handler could reap the process with pid here resulting in a kill error // if we didnt block it above if(pid){ // child is reaped by the SIGCHLD handler, no need to do it here if(kill(-pid,SIGINT)< 0){ safe_printf("Could not terminate process\n"); } } sigprocmask(SIG_UNBLOCK, &mask, NULL); return; }
// // TODO: Include your function header here // static void sig_handler(int sig) { int status; pid_t pid; switch(sig) { case SIGINT: // use our own thread-safe implemention of printf safe_printf("\n[%d] Server terminated due to keyboard interrupt\n", getpid()); server_running = false; exit(0); break; case SIGCHLD: // TODO: Reutemann fragen wie aufgerufen und was dahinter steckt while((pid=wait3(&status, WNOHANG, (struct rusage *)0)) > 0) printf("Child finished, pid %d.\n", pid); break; default: break; } /* end switch */ } /* end of sig_handler */
DetectionSet DynVolNN::detect(const ImRGBZ&im,DetectionFilter filter) const { SphericalOccupancyMap SOM(im); vector<MatchPacket> packets(templates.size()); TaskBlock proc_templates("proc_templates"); tbb::concurrent_unordered_set<size_t> checked_templates; for(int iter = 0; iter < templates.size(); ++iter) { proc_templates.add_callee([&,iter]() { Timer timer; timer.tic(); const DynVolTempl&t = templates.at(iter); packets.at(iter) = MatchPacket(SOM,t,[&](const Mat&t) { size_t hash = hash_code(t); auto r = checked_templates.insert(hash); if(!r.second) { cout << "template duplicate skipped! " << hash << endl; } return !r.second; }); long interval = timer.toc(); lock_guard<mutex> l(monitor); performance_times[(t.z_min - min_z)/50] += interval; performance_counts[(t.z_min - min_z)/50] ++; }); } proc_templates.execute(); log_file << safe_printf("info: % checked among % templates",checked_templates.size(),templates.size()) << endl; std::sort(packets.begin(),packets.end()); for(int iter = 0; iter < 1; ++iter, iter *= 2) { string fn = im.filename; for(char&c : fn) if(c == '/') c = '_'; packets.at(iter).log(safe_printf("packet_[%]_[%]_",fn,iter),SOM); } log_times(); DetectionSet all_dets; TaskBlock take_dets("take_dets"); int stride = 1; for(int yIter = stride/2; yIter < im.rows(); yIter += stride) take_dets.add_callee([&,yIter]() { for(int xIter = stride/2; xIter < im.cols(); xIter += stride) { float max_resp = -inf; Rect max_bb; for(auto && packet : packets) { if(packet.bb.size().area() <= 0) continue; if(yIter < packet.r.rows && xIter < packet.r.cols) { float resp = packet.r.at<float>(yIter,xIter); if(resp > max_resp) { max_resp = resp; max_bb = Rect(Point(xIter,yIter),packet.bb.size()); } } }//end for packet auto det = make_shared<Detection>(); det->BB = max_bb; det->resp = max_resp; static mutex m; lock_guard<mutex> l(m); all_dets.push_back(det); }// end for xIter }); take_dets.execute(); all_dets = sort(all_dets); return (all_dets); }
/** * Default exception handler. Prints out the exception * cause decode and all relevant registers. * * @param registers Registers at time of the exception */ static void cvmx_interrupt_default_exception_handler(uint64_t registers[32]) { uint64_t trap_print_cause; ebt3000_str_write("Trap"); cvmx_spinlock_lock(&cvmx_interrupt_default_lock); safe_printf("******************************************************************\n"); safe_printf("Core %lu: Unhandled Exception. Cause register decodes to:\n", cvmx_get_core_num()); READ_COP0(trap_print_cause, COP0_CAUSE); switch ((trap_print_cause >> 2) & 0x1f) { case 0x0: safe_printf("Interrupt\n"); break; case 0x1: safe_printf("TLB Mod\n"); break; case 0x2: safe_printf("tlb load/fetch\n"); break; case 0x3: safe_printf("tlb store\n"); break; case 0x4: safe_printf("address exc, load/fetch\n"); break; case 0x5: safe_printf("address exc, store\n"); break; case 0x6: safe_printf("bus error, inst. fetch\n"); break; case 0x7: safe_printf("bus error, load/store\n"); break; case 0x8: safe_printf("syscall\n"); break; case 0x9: safe_printf("breakpoint \n"); break; case 0xa: safe_printf("reserved instruction\n"); break; case 0xb: safe_printf("cop unusable\n"); break; case 0xc: safe_printf("arithmetic overflow\n"); break; case 0xd: safe_printf("trap\n"); break; case 0xf: safe_printf("floating point exc\n"); break; case 0x12: safe_printf("cop2 exception\n"); break; case 0x16: safe_printf("mdmx unusable\n"); break; case 0x17: safe_printf("watch\n"); break; case 0x18: safe_printf("machine check\n"); break; case 0x1e: safe_printf("cache error\n"); break; default: safe_printf("Reserved exception cause.\n"); break; } safe_printf("******************************************************************\n"); cvmx_interrupt_dump_registers(registers); safe_printf("******************************************************************\n"); cvmx_spinlock_unlock(&cvmx_interrupt_default_lock); while (1) { if (cvmx_sysinfo_get()->board_type == CVMX_BOARD_TYPE_SIM) asm volatile ("break 1"); else asm volatile ("wait"); }
int process_smpl_buffer(void) { perfmon_smpl_hdr_t *hdr = (perfmon_smpl_hdr_t *)smpl_vaddr; perfmon_smpl_entry_t *ent; unsigned long pos; unsigned long smpl_entry = 0; pfm_ita2_reg_t *reg, *pmd16; int i, ret; /* * Make sure the kernel uses the format we understand */ if (PFM_VERSION_MAJOR(hdr->hdr_version) != PFM_VERSION_MAJOR(PFM_SMPL_VERSION)) { fatal_error("Perfmon v%u.%u sampling format is not supported\n", PFM_VERSION_MAJOR(hdr->hdr_version), PFM_VERSION_MINOR(hdr->hdr_version)); } pos = (unsigned long)(hdr+1); /* * walk through all the entries recored in the buffer */ for(i=0; i < hdr->hdr_count; i++) { ret = 0; ent = (perfmon_smpl_entry_t *)pos; /* * print entry header */ safe_printf("Entry %ld PID:%d CPU:%d STAMP:0x%lx IIP:0x%016lx\n", smpl_entry++, ent->pid, ent->cpu, ent->stamp, ent->ip); /* * point to first recorded register (always contiguous with entry header) */ reg = (pfm_ita2_reg_t*)(ent+1); /* * in this particular example, we have pmd8-pmd15 has the BTB. We have also * included pmd16 (BTB index) has part of the registers to record. This trick * allows us to get the index to decode the sequential order of the BTB. * * Recorded registers are always recorded in increasing order. So we know * that pmd16 is at a fixed offset (+8*sizeof(unsigned long)) from pmd8. */ pmd16 = reg+8; show_btb(reg, pmd16); /* * move to next entry */ pos += hdr->hdr_entry_size; } return 0; }
/* * main - The shell's main routine */ int main(int argc, char **argv) { char c; char cmdline[MAXLINE]; /* cmdline for fgets */ int emit_prompt = 1; /* emit prompt (default) */ /* Redirect stderr to stdout (so that driver will get all output * on the pipe connected to stdout) */ dup2(1, 2); /* Parse the command line */ while ((c = getopt(argc, argv, "hvp")) != EOF) { switch (c) { case 'h': /* print help message */ usage(); break; case 'v': /* emit additional diagnostic info */ verbose = 1; break; case 'p': /* don't print a prompt */ emit_prompt = 0; /* handy for automatic testing */ break; default: usage(); } } /* Install the signal handlers */ /* These are the ones you will need to implement */ Signal(SIGINT, sigint_handler); /* ctrl-c */ Signal(SIGTSTP, sigtstp_handler); /* ctrl-z */ Signal(SIGCHLD, sigchld_handler); /* Terminated or stopped child */ Signal(SIGTTIN, SIG_IGN); Signal(SIGTTOU, SIG_IGN); /* This one provides a clean way to kill the shell */ Signal(SIGQUIT, sigquit_handler); /* Initialize the job list */ initjobs(job_list); /* Execute the shell's read/eval loop */ while (1) { if (emit_prompt) { //printf("%s", prompt); safe_printf("%s", prompt); fflush(stdout); } if ((fgets(cmdline, MAXLINE, stdin) == NULL) && ferror(stdin)) app_error("fgets error"); if (feof(stdin)) { /* End of file (ctrl-d) */ printf ("\n"); fflush(stdout); fflush(stderr); exit(0); } /* Remove the trailing newline */ cmdline[strlen(cmdline)-1] = '\0'; /* Evaluate the command line */ eval(cmdline); fflush(stdout); fflush(stdout); } exit(0); /* control never reaches here */ }
int es_interface(int s, const void *data, size_t size) { int idx = 0 , retval = 0; char input_buf[RECV_BUF_SIZE+1]; // Copy the data into 'input_buf' memset( input_buf , 0 , RECV_BUF_SIZE+1 ); strncpy( input_buf , data , size ); char *commands[NTELNETCOMMANDS] = { "esinit" , "esread" , "esdone" , "esdisable" , "mwr" , "mrd" , "debug" , \ "dbgeyescan" , "initclk" , "readclk" , "printupod" , "iicr" , "iicw" , "printtemp" , "globalinit" }; if( !strncmp( input_buf , "h" , 1 ) || !strncmp( input_buf , "H" , 1 ) ) { memset( input_buf , 0 , RECV_BUF_SIZE+1 ); safe_sprintf( input_buf , "commands :" ); for( idx = 0 ; idx < NTELNETCOMMANDS ; idx++ ) { safe_sprintf( input_buf , "%s %s" , input_buf , commands[idx] ); } safe_sprintf( input_buf , "%s\r\n" , input_buf ); return safe_send(s, input_buf); } char * temp_str , ** pEnd = NULL; typedef enum { ESINIT = 0 , ESREAD = 1 , ESDONE = 2 , ESDISABLE = 3 , MWR = 4 , MRD = 5 , DEBUG = 6 , \ DBGEYESCAN = 7 , INITCLK = 8 , READCLK = 9 , PRINTUPOD = 10 , IICR = 11 , IICW = 12 , PRINTTEMP = 13 , GLOBALINIT = 14 } command_type_t; command_type_t command_type = MWR; char tokens[NTELNETTOKENS][20] = {}; for( idx = 0 ; idx < NTELNETTOKENS ; idx++ ) { memset( tokens[idx] , 0 , 20 ); } // tokenize (strtok) the input and store in tokens[] temp_str = strtok( input_buf , " " ); int number_tokens = 0; while( temp_str != NULL ) { strncpy( tokens[number_tokens] , temp_str , strlen( temp_str ) ); ++number_tokens; temp_str = strtok( NULL , " {},\r\n"); } // identify the command for( idx = 0 ; idx < NTELNETCOMMANDS ; ++idx ) { if( !strncmp( commands[idx] , tokens[0] , strlen(commands[idx]) ) ) command_type = idx; } if( command_type == ESINIT ) { if( number_tokens == 2 ) { if( !strncmp( "run" , tokens[1] , 3 ) ) { global_run_eye_scan(); return safe_send( s , "1\r\n" ); } } if( number_tokens != 8 ) { memset( input_buf , 0 , RECV_BUF_SIZE+1 ); safe_sprintf( input_buf , "Syntax: esinit <lane> <max_prescale> <horz_step> <data_width> <vert_step> <lpm_mode> <rate>\r\n"); return safe_send( s , input_buf ); } int curr_lane = strtoul( tokens[1] , pEnd , 0); xaxi_eyescan_enable_channel(curr_lane); eyescan_lock(); eye_scan * curr_eyescan = get_eye_scan_lane( curr_lane ); if( curr_eyescan == NULL ) { return safe_send( s , "error, no lane found\r\n" ); } curr_eyescan->pixel_count = 0; curr_eyescan->state = WAIT_STATE; curr_eyescan->p_upload_rdy = 0; // Read values in curr_eyescan->max_prescale = strtoul( tokens[2] , pEnd , 0); curr_eyescan->horz_step_size = strtoul( tokens[3] , pEnd , 0); curr_eyescan->data_width = strtoul( tokens[4] , pEnd , 0); curr_eyescan->vert_step_size = strtoul( tokens[5] , pEnd , 0); curr_eyescan->lpm_mode = strtoul( tokens[6] , pEnd , 0); curr_eyescan->max_horz_offset = strtoul( tokens[7] , pEnd , 0); // same as rate? //retval = configure_eye_scan( curr_eyescan , curr_lane ); curr_eyescan->enable = TRUE; // enable the lane curr_eyescan->initialized = FALSE; // need to reinitialize lane eyescan_unlock(); return 0; } if( command_type == ESREAD ) { memset( input_buf , 0 , RECV_BUF_SIZE+1 ); if( number_tokens != 3 && number_tokens != 2 ) { safe_sprintf( input_buf , "Syntax: esread <lane> <pixel>\r\n"); return safe_send( s , input_buf ); } if( !strncmp( "all" , tokens[1] , 3 ) ) { if( !global_upload_ready() ) return 0; int curr_lane = 0; for( curr_lane = 0 ; curr_lane < MAX_NUMBER_OF_LANES ; curr_lane++ ) { eye_scan * curr_eyescan = get_eye_scan_lane( curr_lane ); if( curr_eyescan == NULL || curr_eyescan->enable == FALSE || curr_eyescan->p_upload_rdy == FALSE ) continue; for( idx = 0 ; idx < curr_eyescan->pixel_count ; idx++ ) { eye_scan_pixel * current_pixel = ( curr_eyescan->pixels + idx ); safe_sprintf( input_buf , "%s%d %d %d %d: %d %d %d %d %ld\r\n" , input_buf, curr_lane , idx , \ current_pixel->h_offset , current_pixel->v_offset , \ current_pixel->error_count , current_pixel->sample_count , \ current_pixel->prescale & 0x001F , current_pixel->ut_sign , current_pixel->center_error ); if( strlen(input_buf) > 1900 ) { retval = safe_send(s, input_buf); memset( input_buf , 0 , RECV_BUF_SIZE+1 ); } } } if( strlen(input_buf) > 0 ) { retval = safe_send(s, input_buf); } return retval; } int curr_lane = strtoul( tokens[1] , pEnd , 0 ); eye_scan * curr_eyescan = get_eye_scan_lane( curr_lane ); if( curr_eyescan == NULL ) { return safe_send( s , "error, no lane found\r\n" ); } if( number_tokens == 2 ) { safe_sprintf( input_buf , "%d\r\n" , curr_eyescan->pixel_count ); retval = safe_send(s, input_buf); return retval; } else { int curr_pixel = strtoul( tokens[2] , pEnd , 0 ); int begin_pixel = curr_pixel; int end_pixel = curr_pixel + 1; if( curr_pixel == curr_eyescan->pixel_count ) { begin_pixel = 0; end_pixel = curr_eyescan->pixel_count; } else if( curr_pixel > curr_eyescan->pixel_count ) { return 0; } for( idx = begin_pixel ; idx <= end_pixel ; idx++ ) { eye_scan_pixel * current_pixel = ( curr_eyescan->pixels + idx ); safe_sprintf( input_buf , "%s%d %d %d %d: %d %d %d %d %ld\r\n" , input_buf, curr_lane , idx , \ current_pixel->h_offset , current_pixel->v_offset , \ current_pixel->error_count , current_pixel->sample_count , \ current_pixel->prescale & 0x001F , current_pixel->ut_sign , current_pixel->center_error ); if( strlen(input_buf) > 1900 ) { retval = safe_send(s, input_buf); memset( input_buf , 0 , RECV_BUF_SIZE+1 ); } } if( strlen(input_buf) > 0 ) { retval = safe_send(s, input_buf); } return retval; } } if( command_type == ESDONE ) { if( number_tokens != 2 ) { memset( input_buf , 0 , RECV_BUF_SIZE+1 ); safe_sprintf( input_buf , "Syntax: esdone <lane> \r\n"); return safe_send( s , input_buf ); } if( !strncmp( "all" , tokens[1] , 3 ) ) { memset( input_buf , 0 , RECV_BUF_SIZE+1 ); safe_sprintf( input_buf , "%d\r\n" , global_upload_ready() ); return safe_send(s, input_buf); } int curr_lane = strtoul( tokens[1] , pEnd , 0); int is_ready = FALSE; eye_scan * curr_eyescan = get_eye_scan_lane( curr_lane ); if( curr_eyescan == NULL ) { return safe_send( s , "error, no lane found\r\n" ); } is_ready = curr_eyescan->p_upload_rdy; memset( input_buf , 0 , RECV_BUF_SIZE+1 ); safe_sprintf( input_buf , "%d: %d\r\n" , curr_lane , is_ready ); return safe_send(s, input_buf); } if( command_type == ESDISABLE ) { if( number_tokens != 2 ) { memset( input_buf , 0 , RECV_BUF_SIZE+1 ); safe_sprintf( input_buf , "Syntax: esdisable <lane> \r\n"); return safe_send( s , input_buf ); } if( !strncmp( "all" , tokens[1] , 3 ) ) { global_stop_eye_scan(); global_upload_unrdy(); return 0; } // Disable the eyescan int curr_lane = strtoul( tokens[1] , pEnd , 0); eye_scan * curr_eyescan = get_eye_scan_lane( curr_lane ); curr_eyescan->enable = FALSE; // Turn off the GTX for this channel xaxi_eyescan_disable_channel(curr_lane); return 0; } typedef enum { N=-1 , W = 0 , H = 1 , B = 2 } wtype_t; wtype_t wtype = N; char *wtypes[3] = { "w" , "h" , "b" }; uint wtype_sizes[3] = { 8 , 4 , 2 }; if( command_type == MWR || command_type == MRD ) { for( idx = 0 ; idx < 3 ; idx++ ){ if( !strncmp( wtypes[idx] , tokens[number_tokens-1] , 1 ) ) wtype = idx; } } u16_t number_of_words = 1; if( command_type == MRD ) { if( number_tokens == 2 ) number_of_words = 0; else if( number_tokens > 2 ) { if( wtype == N ) { number_of_words = strtoul( tokens[number_tokens-1] , pEnd , 0 ); } else { number_of_words = strtoul( tokens[number_tokens-2] , pEnd , 0 ); } } } else if( command_type == MWR ) { if( number_tokens == 3 ) number_of_words = 1; else if( number_tokens > 3 ) { if( wtype == N ) { number_of_words = strtoul( tokens[number_tokens-1] , pEnd , 0 ); } else { number_of_words = strtoul( tokens[number_tokens-2] , pEnd , 0 ); } } } if( command_type == MRD && number_tokens == 2 ) number_of_words = 1; u32_t address = 0; u32_t addresses[NTELNETTOKENS] = {0}; u32_t values[NTELNETTOKENS] = {0}; if( command_type == MWR || command_type == MRD ) { if( number_tokens > 1 ) { address = strtoul( tokens[1] , pEnd , 0 ); } } if( command_type == MWR ) { for( idx = 0 ; idx < number_of_words ; idx++ ) { values[idx] = strtoul( tokens[idx+2] , pEnd , 0 ); if( wtype == N || wtype == W ) { /* WORD, u32_t */ u32_t * tval = NULL; tval = ( (u32_t*)address + idx ); *tval = (u32_t)values[idx]; } else if( wtype == H ) { /* HALF, u16_t */ u16_t * tval = NULL; tval = ( (u16_t*)address + idx ); *tval = (u16_t)values[idx]; } else if( wtype == B ) { /* BYTE, u8_t */ u8_t * tval = NULL; tval = ( (u8_t*)address + idx ); *tval = (u8_t)values[idx]; } } } if( command_type == MRD ) { for( idx = 0 ; idx < number_of_words ; idx++ ) { if( wtype == N || wtype == W ) { /* WORD, u32_t */ u32_t * tval = NULL; tval = ( (u32_t*)address + idx ); addresses[idx] = (u32_t)tval; values[idx] = *tval; } else if( wtype == H ) { /* HALF, u16_t */ u16_t * tval = NULL; tval = ( (u16_t*)address + idx ); addresses[idx] = (u32_t)tval; values[idx] = *tval; } else if( wtype == B ) { /* BYTE, u8_t */ u8_t * tval = NULL; tval = ( (u8_t*)address + idx ); addresses[idx] = (u32_t)tval; values[idx] = *tval; } } return retval; } if( command_type == MRD ) { char format_string[20]; memset( format_string , 0 , 20 ); if( wtype >= 0 ) sprintf( format_string , "%%p: 0x%%0%dlx\r\n" , wtype_sizes[wtype] ); else sprintf( format_string , "%%p: 0x%%0%dlx\r\n" , wtype_sizes[0] ); for( idx = 0 ; idx < number_of_words ; idx++ ) { memset( input_buf , 0 , RECV_BUF_SIZE+1); safe_sprintf( input_buf , format_string , addresses[idx] , values[idx] ); retval = safe_send(s, input_buf); } return retval; } if( command_type == DEBUG ) { srand( time(NULL) ); safe_sprintf( input_buf , "echo mrd %p 4 b | nc 192.168.1.99 7\r\n" , u8_test_array ); retval = safe_send(s, input_buf); safe_sprintf( input_buf , "echo mwr %p {0x%02x 0x%02x 0x%02x 0x%02x} 4 b | nc 192.168.1.99 7\r\n" , u8_test_array , (u8_t)rand() , (u8_t)rand() , (u8_t)rand() , (u8_t)rand() ); retval = safe_send(s, input_buf); safe_sprintf( input_buf , "echo mrd %p 4 b | nc 192.168.1.99 7\r\n" , u8_test_array ); retval = safe_send(s, input_buf); safe_sprintf( input_buf , "echo mrd %p 4 h | nc 192.168.1.99 7\r\n" , u16_test_array ); retval = safe_send(s, input_buf); safe_sprintf( input_buf , "echo mwr %p {0x%04x 0x%04x 0x%04x 0x%04x} 4 h | nc 192.168.1.99 7\r\n" , u16_test_array , (u16_t)rand() , (u16_t)rand() , (u16_t)rand() , (u16_t)rand() ); retval = safe_send(s, input_buf); safe_sprintf( input_buf , "echo mrd %p 4 h | nc 192.168.1.99 7\r\n" , u16_test_array ); retval = safe_send(s, input_buf); safe_sprintf( input_buf , "echo mrd %p 4 w | nc 192.168.1.99 7\r\n" , u32_test_array ); retval = safe_send(s, input_buf); safe_sprintf( input_buf , "echo mwr %p {0x%08lx 0x%08lx 0x%08lx 0x%08lx} 4 w | nc 192.168.1.99 7\r\n" , u32_test_array , (u32_t)rand() , (u32_t)rand() , (u32_t)rand() , (u32_t)rand() ); retval = safe_send(s, input_buf); safe_sprintf( input_buf , "echo mrd %p 4 w | nc 192.168.1.99 7\r\n" , u32_test_array ); retval = safe_send(s, input_buf); return retval; } if( command_type == DBGEYESCAN ) { int curr_lane = -1; memset( input_buf , 0 , RECV_BUF_SIZE+1 ); if( number_tokens == 2 ) { curr_lane = strtoul( tokens[1] , pEnd , 0 ); } eyescan_debugging( curr_lane , input_buf ); if( curr_lane == -1 ) { retval = safe_send( s , input_buf ); return retval; } u32 drp_addresses[146] = { \ 0x000, 0x00D, 0x00E, 0x00F, 0x011, 0x012, 0x013, 0x014, 0x015, 0x016, 0x018, 0x019, 0x01A, 0x01B, 0x01C, 0x01D, 0x01E, 0x01F, 0x020, \ 0x021, 0x022, 0x023, 0x024, 0x025, 0x026, 0x027, 0x028, 0x029, 0x02A, 0x02B, 0x02C, 0x02D, 0x02E, 0x02F, 0x030, 0x031, 0x032, 0x033, \ 0x034, 0x035, 0x036, 0x037, 0x038, 0x039, 0x03A, 0x03B, 0x03C, 0x03D, 0x03E, 0x03F, 0x040, 0x041, 0x044, 0x045, 0x046, 0x047, 0x048, \ 0x049, 0x04A, 0x04B, 0x04C, 0x04D, 0x04E, 0x04F, 0x050, 0x051, 0x052, 0x053, 0x054, 0x055, 0x056, 0x057, 0x059, 0x05B, 0x05C, 0x05D, \ 0x05E, 0x05F, 0x060, 0x061, 0x062, 0x063, 0x064, 0x065, 0x066, 0x068, 0x069, 0x06A, 0x06B, 0x06F, 0x070, 0x071, 0x074, 0x075, 0x076, \ 0x077, 0x078, 0x079, 0x07A, 0x07C, 0x07D, 0x07F, 0x082, 0x083, 0x086, 0x087, 0x088, 0x08C, 0x091, 0x092, 0x097, 0x098, 0x099, 0x09A, \ 0x09B, 0x09C, 0x09D, 0x09F, 0x0A0, 0x0A1, 0x0A2, 0x0A3, 0x0A4, 0x0A5, 0x0A6, 0x0A7, 0x0A8, 0x0A9, 0x0AA, 0x0AB, 0x0AC ,\ 0x14F, 0x150, 0x151, 0x152, 0x153, 0x154, 0x155, 0x156, 0x157, 0x158, 0x159, 0x15A, 0x15B , 0x15C, 0x15D \ }; for( idx = 0 ; idx < 146 ; idx++ ) { eyescan_debug_addr( curr_lane , drp_addresses[idx] , input_buf ); if( strlen(input_buf) > 1900 ) { retval = safe_send( s , input_buf ); memset( input_buf , 0 , RECV_BUF_SIZE+1 ); } } if( strlen(input_buf) > 0 ) { retval = safe_send( s , input_buf ); memset( input_buf , 0 , RECV_BUF_SIZE+1 ); } return retval; } if( command_type == INITCLK ) { #ifdef IS_OTC_BOARD SetClockDevID(0); retval = 0; if( number_tokens == 1 ) { retval = InitClockRegisters(); return retval; } else if( number_tokens == 2 ) { char * freqs[4] = { "125.000 MHz" , "148.778 MHz" , "200.395 MHz" , "299.000 MHz" }; u16 regvals[4][21] = { { 0x01b9, 0x24c4, 0x74fa, 0x04fa, 0x306f, 0x0023, 0x0003, 0x0023, 0x0003, 0x00c3, 0x0030, 0x0000, 0x00c3, 0x0030, 0x0000, 0x00c3, 0x0030, 0x0000, 0x00c3, 0x0030, 0x0000 } , { 0x01b9, 0x11e9, 0x5c3c, 0x04f0, 0x306f, 0x0023, 0x0004, 0x0023, 0x0004, 0x00c3, 0x0040, 0x0000, 0x00c3, 0x0040, 0x0000, 0x00c3, 0x0040, 0x0000, 0x00c3, 0x0040, 0x0000 } , { 0x01b9, 0x000c, 0x003b, 0x04f5, 0x306f, 0x0023, 0x0002, 0x0023, 0x0002, 0x00c3, 0x0020, 0x0000, 0x00c3, 0x0020, 0x0000, 0x00c3, 0x0020, 0x0000, 0x00c3, 0x0020, 0x0000 } , { 0x01b1, 0x21f5, 0xc846, 0x04f5, 0x306f, 0x0023, 0x0001, 0x0023, 0x0001, 0x00c3, 0x0010, 0x0000, 0x00c3, 0x0010, 0x0000, 0x00c3, 0x0010, 0x0000, 0x00c3, 0x0010, 0x0000 } }; int fidx = strtoul( tokens[1] , pEnd , 0); if( fidx >= 0 && fidx < 4 ) { u16 regval[21]; for( idx = 0 ; idx<21 ; idx++ ) { regval[idx] = regvals[fidx][idx]; } memset( input_buf , 0 , RECV_BUF_SIZE+1 ); safe_sprintf( input_buf , "Using clock frequency of %s\n" , freqs[fidx] ); retval = safe_send( s , input_buf ); retval = InitClockRegisters( regval ); return retval; } else { safe_printf( "Can't init clock\n"); return 0; } } else if( number_tokens == 22 ) { u16 regval[21]; for( idx = 1 ; idx<22 ; idx++ ) { regval[idx-1] = strtoul( tokens[idx] , pEnd , 0); } retval = InitClockRegisters( regval ); return retval; } else { safe_printf( "Can't init clock\n"); return 0; } #endif return retval; } if( command_type == READCLK ) { #ifdef IS_OTC_BOARD u16 *cfgdata = GetClockConfig(); memset( input_buf , 0 , RECV_BUF_SIZE+1 ); for( idx = 0 ; idx < 21 ; idx++ ) { safe_sprintf( input_buf , "%s %04d " , input_buf , idx ); } safe_sprintf( input_buf , "%s\r\n" , input_buf ); retval = safe_send(s, input_buf); memset( input_buf , 0 , RECV_BUF_SIZE+1 ); for( idx = 0 ; idx < 21 ; idx++ ) { safe_sprintf( input_buf , "%s0x%04x " , input_buf , cfgdata[idx] ); } safe_sprintf( input_buf , "%s\r\n" , input_buf ); retval = safe_send(s, input_buf); free(cfgdata); #endif return retval; } if( command_type == PRINTUPOD ) { #ifdef IS_OTC_BOARD u8_t i2c_addresses[8]; for( idx=0 ; idx<8; idx++ ) i2c_addresses[idx] = idx; for( idx=1 ; idx < number_tokens ; idx++ ) i2c_addresses[idx-1] = strtoul( tokens[idx] , pEnd , 0 ); for( idx=0;idx<8;idx++ ) { if( number_tokens > 1 && idx>=(number_tokens-1) ) continue; u8_t i2c_addr = i2c_addresses[idx]; if( i2c_addr < 8 ) { i2c_addr = upod_address(i2c_addr); } SetUPodI2CAddress( i2c_addr ); uPodMonitorData *mondata = GetUPodStatus(); memset( input_buf , 0 , RECV_BUF_SIZE+1 ); char * temp_format_string = "Addr %p , status 0x%02x , temp %d.%03dC , 3.3V %duV , 2.5V %duV\n"; safe_sprintf( input_buf , temp_format_string , i2c_addr , mondata->status, \ mondata->tempWhole, mondata->tempFrac, \ 100*mondata->v33, 100*mondata->v25); free(mondata); retval = safe_send(s, input_buf); } #endif return retval; } if( command_type == IICR ) { #ifdef IS_OTC_BOARD int devid = 0; u8_t i2c_addr; u8_t regaddr; u8_t * data; u16_t nbytes = 1; devid = strtoul( tokens[1] , pEnd , 0 ); i2c_addr = strtoul( tokens[2] , pEnd , 0 ); regaddr = strtoul( tokens[3] , pEnd , 0 ); if( number_tokens == 5 ) nbytes = strtoul( tokens[4] , pEnd , 0 ); data = malloc( sizeof(u8_t) * nbytes ); /* Set the register address */ retval = IICMasterWrite(devid,i2c_addr,1,®addr); if( retval != XST_SUCCESS ) return retval; /* and do the read */ retval = IICMasterRead(devid,i2c_addr,nbytes,data); memset( input_buf , 0 , RECV_BUF_SIZE+1 ); for( idx = 0 ; idx < nbytes ; idx++ ) { safe_sprintf( input_buf , "%s 0x%02x" , input_buf , data[idx] ); } safe_sprintf( input_buf , "%s\r\n" , input_buf ); retval = safe_send(s, input_buf); free(data); #endif return retval; } if( command_type == IICW ) { #ifdef IS_OTC_BOARD int devid = 0; u8_t i2c_addr; u8_t regaddr; u8_t * buffer; u16_t nbytes = ( number_tokens - 4 ); devid = strtoul( tokens[1] , pEnd , 0 ); i2c_addr = strtoul( tokens[2] , pEnd , 0 ); regaddr = strtoul( tokens[3] , pEnd , 0 ); buffer = malloc( sizeof(u8_t) * ( nbytes + 1 ) ); buffer[0] = regaddr; for( idx = 4 ; idx < number_tokens ; idx++ ) { buffer[idx-3] = strtoul( tokens[idx] , pEnd , 0 ); } retval = IICMasterWrite(devid,i2c_addr,nbytes+1,buffer); free(buffer); #endif return retval; } if( command_type == PRINTTEMP ) { // We now update this in monitor, don't bother doing it twice... /* now write the web page data in two steps. FIrst the Xilinx temp/voltages */ char *pagefmt = "uptime %d , temp %0.1fC , intv %0.1fV , auxv %0.1fV , bramv %0.1fV\r\n"; safe_sprintf(input_buf,pagefmt,procStatus.uptime,procStatus.v7temp,procStatus.v7vCCINT,procStatus.v7vCCAUX,procStatus.v7vBRAM); int n=strlen(input_buf); int w; if ((w = safe_send(s, input_buf)) < 0 ) { safe_printf("error writing web page data (part 1) to socket\r\n"); safe_printf("attempted to lwip_write %d bytes, actual bytes written = %d\r\n", n, w); return -2; } return w; } if( command_type == GLOBALINIT ) { global_reset_eye_scan(); } return retval; }