Monday, 15 June 2015

mips - Count number of lowercase letters -



mips - Count number of lowercase letters -

so have created programme count number of lowercase letters in string. problem having when reach end of string , nl character reached, line beq $t0, $t1, end not beingness executed; continues indefinitely. i'm not sure i'm doing incorrectly.

.data msg1: .word 0:24 .text .globl main main: addu $s0, $0, $ra li $v0, 8 la $a0, msg1 la $a1, 100 syscall loop: lb $t0, 4($a0) li $t1, 0x0a beq $t0, $t1, end continue: li $t1, 'a' blt $t0, $t1, count li $t1, 'z' bgt $t0, $t1, count count: addi $t4, $t4, 1 j loop end: li $v0, 1 addu $a0, $t2, $0 syscall jr $ra

you compare 4($a0) 0x0a on each iteration of loop, never alter $a0 in loop, not advancing through string , never @ \n @ end of string.

there few other bugs in code.

use @ start of loop:

loop: lb $t0, 0($a0) addiu $a0, $a0, 1 ...

mips

Half Duplex RS485 linux Serial USB Programing in C -



Half Duplex RS485 linux Serial USB Programing in C -

i'm trying setup half duplex communication in ubuntu 14.04 in program. have rs485 transceiver using rts line toggle , forth between transmit , receive. i'm using speak when spoken scheme , programme master. problem rts isn't toggling off when i'm done sending bundle can receive data. want turn rts high, send data, turn rts low, read data. help great.

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <termios.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/signal.h> #include <sys/types.h> #define baudrate b38400 #define comport "/dev/ttyusb0" #define _posix_source 1 #define false 0 #define true 1 #define stx_keypad 0xe1 #define payload_buff_size 256 #define crc_hi 0xd8 #define crc_low 0xc3 volatile int stop=false; int ser_port; int bus_address = 1; int message_length = 0; struct termios oldtio,newtio; unsigned char rxbuf[256]; unsigned char tx_flags = 0; void opencommport(); void sendserial(); int setrts(int level); int main(void) { printf("starting...\r\n"); opencommport(); setrts(1); printf("sending serial data\r\n"); sendserial(); setrts(0); //close(ser_port); printf("all done\r\n"); homecoming exit_success; } void opencommport() { ser_port = open(comport, o_rdwr | o_noctty | o_nonblock); if (ser_port == -1) { perror(comport); perror("unable open port"); exit(-1); } if(tcgetattr(ser_port,&oldtio) <0)// save current port settings { perror(comport); perror("couldn't old terminal attributes"); exit (-1); } bzero(&newtio, sizeof(newtio)); newtio.c_cflag = baudrate | cs8 | clocal | cread | crtscts; newtio.c_iflag = ignpar | icanon; newtio.c_oflag = 0; // set input mode (non-c, no echo,...) newtio.c_lflag = 0; newtio.c_cc[vtime] = 0; // inter-character timer unused newtio.c_cc[vmin] = 0; // blocking read until 5 chars received tcflush(ser_port, tciflush); tcsetattr(ser_port,tcsanow,&newtio); } void sendserial() { unsigned char tx_header[6]; tx_header[0] = stx_keypad; tx_header[1] = bus_address; tx_header[2] = tx_flags; tx_header[3] = message_length; tx_header[4] = crc_hi; tx_header[5] = crc_low; if((write(ser_port, tx_header, 6)) != 6) { printf("error sending data! not bytes sent\r\n"); } } int setrts(int level) { int status; if (ioctl(ser_port, tiocmget, &status) == -1) { perror("getrts(): tiocmset"); homecoming 0; } if(level) { status |= tiocm_rts; } else { status &= ~tiocm_rts; } if (ioctl(ser_port, tiocmset, &status) == -1) { perror("setrts(): tiocmset"); homecoming 0; } homecoming 1; }

c linux ubuntu serial-port rs485

c# - How to tell count of non-empty strings in string array -



c# - How to tell count of non-empty strings in string array -

i have string pipe delimited:

string line = "test|||tester||test||||||test test|"

i reading intro string array:

string[] wordsarr = line.split(new string[] { "|" }, stringsplitoptions.none);

my goal without manually writing loop myself if there way built framework see how many items in array not empty. can't utilize removeemptyentries property on stringsplitoptions b/c items fall within pipes matter.

any ideas?

if looking count, utilize .count after split.

string line = "test|||tester||test||||||test test|"; int notemptycount = line .split('|') .count(x => !string.isnullorempty(x));

if want filter out items empty , access items remain, utilize .where instead.

var notemptycollection = line .split('|') .where(x => !string.isnullorempty(x));

c# arrays string

Windows Batch - Change the beginning of a path but keep the rest -



Windows Batch - Change the beginning of a path but keep the rest -

i'm running ffmpeg video encoding. have batch file encode files drop on it, keeping file's original name , re-create encoded files specific directory. script "know" original's file path , re-create encoded file path relative it, meaning: original file dropped on batch file in c:\some\folder\show\season\episode\file.mov encoded file should encoded d:\different\directory\show\season\episode\file.mp4 part of path until \show fixed.

this have far:

@echo on set count=0 %%a in (%*) (<br> if exist %%a ( md \\specific\path\"%%~na" %myfiles%\ffmpeg.exe -i "%%~a" -vcodec libx264 -preset medium -vprofile baseline -level 3.0 -b 500k -vf scale=640:-1 -acodec aac -strict -2 -ac 2 -ab 64k -ar 48000 "%%~na_500.mp4" re-create "%%~na_500.mp4" "\\specific\path\"%%~na"\%%~na_500.mp4" re-create "%%~na_500.mp4" "\\specific\path\"%%~na"\%%~na_500.mp4" del "%%~na_500.mp4"

set /a count+=1

) else ( echo skipping non-existent %%~a

thank you, oren

class="lang-dos prettyprint-override">@echo off setlocal set "myfiles=my_files" set "fixed_path=u:\destdir" %%a in ("%*") if exist "%%a" ( /f "tokens=3*delims=\" %%b in ("%%~dpa") ( echo(md "%fixed_path%\%%c" echo(%myfiles%\ffmpeg.exe -i "%%~a" -vcodec libx264 -preset medium -vprofile baseline -level 3.0 -b 500k -vf scale=640:-1 -acodec aac -strict -2 -ac 2 -ab 64k -ar 48000 "%%~na_500.mp4" echo(copy "%%~na_500.mp4" "%fixed_path%\%%c%%~na_500.mp4" echo(del "%%~na_500.mp4" ) ) else (echo(%%~a not exist ) goto :eof

the required md commands simply echoed testing purposes. after you've verified commands correct, alter echo(md md create directories. append 2>nul suppress error messages (eg. when directory exists)

similarly, del , copy commands simply echoed.

i set myfiles constant - no uncertainty yours different , set fixed _path constant convenience of editing.

no thought whether ffmpeg command right - edited yours, , i'm puzzled utilize of 2 apparently identical copy commands in succession, maybe eyes playing tricks...

windows batch-file ffmpeg

opencv - Draw minimum enclosing circle around a contour in EmguCV -



opencv - Draw minimum enclosing circle around a contour in EmguCV -

how draw minimum enclosing circle around contour in emgucv?. findcontours() method returns set of points. draw circle asks pointf. there work around this? thanks.

yes there way. have convert contour array of pointf this:

for (var contour = binaryimage.findcontours(chain_approx_method.cv_chain_approx_simple, retr_type.cv_retr_ccomp, mem); contour != null; contour = contour.hnext) { //assuming have way of getting index of //point wanted extract current contour var index = 0; pointf[] pointfs = array.convertall(contour.toarray(), input => new pointf(input.x, input.y)); //just illustration var circle = new circlef(pointfs[index], 2.0f); }

opencv image-processing emgucv

linux kernel - Adding boot argument -



linux kernel - Adding boot argument -

i trying understand, how boot arguments created , passed kernel.

i thinking next steps, please confirm.

1.add new boot argument in header file under u-boot source(include/configs/)

my understanding is, each board having 1 header file under "include/configs" of u-boot source. please right me if wrong.

2.modify kernel take new boot argument.

doubht) please tell me modify kernel take new boot argument.

could please guide me understand 1 existing boot arg implementation.

thanks in advance.

correct 1.

i don't know kernel modification. in function receiving arguments (i think stacked in main() function).

linux-kernel u-boot

assembly language, strange loop -



assembly language, strange loop -

i'm struggling understand code does

ldi r20, 80 loop: asr r20 brsh loop nop

what code doing , how many clock cycles code take execute?

this seems atmel avr assembly code. in loop continues until carry bit of status register set, shifts hexadecimal 80 arithmetically right 1 position r20 takes successive values of 80, c0, e0, f0, f8, fc, fe, ff. until now, low bit has been 0, , value has been shifted carry bit of status register. on next shift, low bit of ff shifted, 1. causes loop exit.

see http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_asr.html on asr instruction.

the net effect cause little delay.

assembly