Simulate ubifs on PC

Here is a step by step way of simulate UBIFS on PC, We use nandsim on UBUNTU 14.04 sudo rmmod nandsim cat /proc/mtd Create 256M Flash in PC's RAM sudo modprobe nandsim first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte=0x15 Check mtd0 created! cat /proc/mtd Attach Ubi0 to mtd0! sudo modprobe ubi mtd=0 Make a volume on ubi0, with... Continue Reading →

Recovering iPhone4

I had an iPhone4 for some time, I give it to my son about 3 year ago, and after 2 years, he bought a  new iPhone 6, so the iPhone4 was left there for 1 year, no one using it. This morning I tried to use it to do some testing, first it won't charge,... Continue Reading →

get all ip names from host name

void get_this_machine_ips(char * retIPs,int len) { char name[255]; PHOSTENT hostinfo;  strcpy(all_ips,""); if( gethostname ( name, sizeof(name)) == 0) { if((hostinfo = gethostbyname(name)) != NULL) { int nCount = 0;    while(hostinfo->h_addr_list[nCount]) { char * temp=inet_ntoa(*(struct in_addr *)hostinfo->h_addr_list[nCount]); CDCS_Log(CDCS_LOG_DBG2, CUR_MODULE, "get_this_machine_ips: %s\n",temp ); strncat(retIPs,temp,20); strcat(retIPs,";"); if (strlen(retIPs)>=(len-25)) break; nCount++; } } } }

Encoding

var str = "𪚥"; Console.WriteLine(str.Length); Console.WriteLine(Char.IsHighSurrogate(str[0])); Console.WriteLine(Char.IsLowSurrogate(str[1])); str = "ส้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้"; Console.WriteLine(str.Length); StringInfo si = new StringInfo(str); Console.WriteLine(si.LengthInTextElements); Did you see above magical string (char)? length is 39!But LengthInTextElements return 1!!

Try catch finally in C#

class Common {     internal static int getInt(string count, int defaultVal)     {         int c = defaultVal;         try         {             c = Convert.ToInt32(count);             return c;         }         catch         {         }         finally         {             int x = 0;         }     return c;     } } Common.getInt("cx", 10); Explaination of this function call: convert will cause exception, catch part will be executed, there is... Continue Reading →

DNP3 in C# Project

After 2 years preparation, I have now able to write a DNP3 client and server C# application. It can support 5000 outstations. User can send integrity poll from master, get response back from client application. DNP3 client can also send unsolicited message to master. Master can write time and date to client. This version of... Continue Reading →

Install MySQL on Windows

I had installed MySQL server on XP. Tried install phpmyadmin to web, changed config.inc.php, but when typing http://localhost/mysql/index.php, nothing happens. Tried install MySQL workbench on Windows 7, tried with root and password, won't work. Looked at following link, http://stackoverflow.com/questions/25736715/mysql-workbench-failed-to-connect-to-mysql-at-xxx-xxx-xxx-with-user-root-host-t It works. mysql> CREATE USER 'randxy'@'localhost' IDENTIFIED BY 'root_password'; mysql> GRANT ALL PRIVILEGES ON *.* TO... Continue Reading →

Create a free website or blog at WordPress.com.

Up ↑