2011/02/13

The chr() in Ruby.

Cause I have to write bytes string using Ruby.

I  collation some rules of chr() to clarify my mind.

At first. create new file.

file = File.new("helloRuby", "w+")

 

There are three way to get the same result :

file.write(65.chr)

file.write(Integer(0x41).chr)

file.write("A")

upon three all get the hexdump result like :

00000000  41                                                |A|


And if using String.hex , ruby will write the string of hex number to file

file.write("A".hex)

00000000  31 30                                             |10|

 

Then, if I want to write the real hex byte to file.

I can using

file.write("A".hex.chr)

file.write(Integer(10).chr)

00000000  0a 0a                                             |..|


Important note :

chr() of Number form and chr() of String form will get the different result !

 

2011/02/08

Cannot identify SD card partition! (mmcblk0: unknown partition table )

Situation :

When I  plug-in my SD card into some EVB board.

SD driver can detect mmcblk0, but cannot detect SD partition.

like below:

# mmc0: new high speed SDHC card at address f7c1
mmcblk0: mmc0:f7c1 SD08G 3.50 GiB
mmcblk0: unknown partition table

 

But if I want to mount SD card to some folder,

I'll need to identify partition of SD card file system.

 

Solution :

After tracing...

Only need to enable CONFIG_MSDOS_PARTITION of kernel config.

then, the partition will be identify!!

# mmc0: new high speed SDHC card at address f7c1
mmcblk0: mmc0:f7c1 SD08G 3.50 GiB
mmcblk0: p1

 

螢幕快照 2011 02 09 下午3 54 36