Monday, December 17, 2012

Time Machine on a network drive

Time Machine on a network drive

Apple’s Time Machine software made it easy to set up incremental back-ups, with one exception: network drives (more formally called network-attached storage, or NAS). Time Machine only directly supports drives formatted with Apple’s HFS+J file system, and will eventually use all disk space on the drive. This page provides an illustrated guide showing how to set up Time Machine on a network drive, using a sparse bundle to emulate a smaller HFS+J drive. Click ‘show screenshot’ after each instruction to see the relevant screenshot.
Note: Many network drives fail to function with Time Machine under OS X Lion due to Apple’s decision to require DHX2 authentication. These NAS devices are awaiting firmware updates from their manufacturers.

Preparation

1. Ensure the network drive is mounted:
1a. Click ‘Go’ and then ‘Network’ and double-click on your network drive. If your network drive is protected, enter your username and password. [show screenshot]
2. Find the name of your computer on the network:
2a. Open System Preferences. [show screenshot]
2b. Click the Sharing icon. [show screenshot]
2c. The computer name on the network is shown below the input field, with a ‘.local’ suffix which should be ignored (that is, if it shows stephenmorley.local then your computer’s network name is stephenmorley). [show screenshot]
3. Ensure Time Machine will show your NAS device:
3a. Click ‘Go’ and then ‘Utilities’. [show screenshot]
3b. Click the Terminal icon. [show screenshot]
3c. Type defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1 and press enter. [show screenshot]
4. Find the MAC address of your computer:
4a. Type ifconfig en0 | grep ether and press enter. Your MAC address is the 17-character string consisting of six pairs of hexadecimal digits separated by colons. [show screenshot]

Creating the sparse bundle

5. Create the sparse bundle:
5a. Type hdiutil create -size 100g -fs HFS+J -volname "Time Machine" NAME_XXXXXXXXXXXX.sparsebundle and press enter, where NAME is the name of your computer on the network (as determined in step 2c) and XXXXXXXXXX is your MAC address (as determined in step 4a) without the colons. Ths will create a 100 gigabyte sparse bundle; to create a sparse bundle of a different size replace 100g with a different value. [show screenshot]
5b. Type rsync -aE NAME_XXXXXXXXXXXX.sparsebundle /Volumes/DRIVE/. and press enter, where DRIVE is the name of your network drive. This will copy the sparse bundle to the network drive, and will take several seconds. [show screenshot]
5c. Type rm -rf NAME_XXXXXXXXXXXX.sparsebundle and press enter. This will delete the copy of the sparse bundle on your computer. You can now close Terminal. [show screenshot]

Setting up Time Machine

6. Select the back-up location:
6a. Click the Time Machine icon and then Open Time Machine Preferences. [show screenshot]
6b. Click the Choose Backup Disk button. [show screenshot]
6c. Select the network drive and then click the Use For Backup button. Time Machine will show the drive’s full capacity, but back-ups will be limited to the size chosen in step 5a. [show screenshot]
7. Start the back-up:
7a. Time Machine will start the back-up automatically after two minutes. Alternative, click the Time Machine icon and then Back Up Now. [show screenshot]
7b. Time Machine will show a status of ‘Preparing…’ while it determines which files to back up. [show screenshot]
7c. After a few minutes the back-up will begin and the status will change to ‘Backing up’. [show screenshot]
7d. While the back-up is in progress, a volume called Time Machine will be shown on the desktop. Once the back-up completes, this volume will disappear. [show screenshot]

Sunday, November 18, 2012

TMLib软件开发库

TMLib软件开发库

【开发历程】
  跟大多数C++程序员一样,我们最早使用MFC开发,开发时间长了,觉得MFC包含的无用的东西过多,编写出来的程序不但体积大,而且速度慢。
  MFC当初是为了简化Windows开发而设计的,但是用它开发行业软件的时候,常常感觉不够专业化,有些MFC封装的太啰嗦,反而是降低了开发效率。
  而且在MFC项目中开发一些更底层的功能时,还得用API。MFC封装太死、封装太啰嗦、对于专业的编程还是不够专业,有些该隐藏的地方没有隐藏,不该隐藏的地方又隐藏了……
  这些理由足够放弃MFC,然后用了一段时间SDK,但是思想还不到用SDK的水平,开发力不从心,又转WTL、又转用别人的类库,用了1年左右用过QT、U++、SmartWin++、wxWidgets、VCF、JUCE、WINX、Win32GUI、Skin+,,感觉到头来还是MFC的另一个版本
  中间曾满怀激情的参与了金山公司的许式伟的国内著名的WinX开源项目,最后因为封装的思想于自己的冲突,再就是WTL存在与MFC相似的缺陷,还是放弃了。
  总结想想,学习了这么多又放弃了,说白了其实就是理想和现实冲突。我们理想的类库总结一下,其实就三点:1:开发简单易用,高开发效率,2,具备高效运行效率和最优部署,3:最终产品具备完美的用户体验。
  最后又回到SDK,这次我们有足够的经验和能力设计个自己开发库(不单是GUI界面库),定名为TMLib。完全用SDK/API开发,参考了不少优秀的类库,封装好,调用简单,代码小,效率高。SDK封装好了,确实比MFC简单直观。

Monday, November 12, 2012

unix - Using getopts in bash shell script to get long and short command line options - Stack Overflow

unix - Using getopts in bash shell script to get long and short command line options - Stack Overflow
** "getopts": with short options AND long options AND short/long arguments **
Works with all combinations, e.G.:
  • foobar -f --bar
  • foobar --foo -b
  • foobar -bf --bar --foobar
  • foobar -fbFBAshorty --bar -FB --arguments=longhorn
  • foobar -fA "text shorty" -B --arguments="text longhorn"
  • bash foobar -F --barfoo
  • sh foobar -B --foobar - ...
  • bash ./foobar -F --bar

#!/bin/bash
# foobar: getopts with short and long options AND arguments
###### some declarations for these example ######
Options=$@
Optnum=$#
sfoo='no '
sbar='no '
sfoobar='no '
sbarfoo='no '
sarguments='no '
sARG=empty
lfoo='no '
lbar='no '
lfoobar='no '
lbarfoo='no '
larguments='no '
lARG=empty

_usage() {
###### U S A G E : Help and ERROR ######
cat <<EOF
 foobar $Options
$*
        Usage: foobar <[options]>
        Options:
                -b   --bar            Set bar to yes    ($foo)
                -f   --foo            Set foo to yes    ($bart)
                -h   --help           Show this message
                -A   --arguments=...  Set arguments to yes ($arguments) AND get ARGUMENT ($ARG)
                -B   --barfoo         Set barfoo to yes ($barfoo)
                -F   --foobar         Set foobar to yes ($foobar)
EOF
}
if [ $# = 0 ]; then _usage "  >>>>>>>> no options given "; fi
##################################################################    
#######  "getopts" with: short options  AND  long options  #######
#######            AND  short/long arguments               #######
while getopts ':bfh-A:BF' OPTION ; do
  case "$OPTION" in
    b  ) sbar=yes                       ;;
    f  ) sfoo=yes                       ;;
    h  ) _usage                         ;;   
    A  ) sarguments=yes;sARG="$OPTARG"  ;;
    B  ) sbarfoo=yes                    ;;
    F  ) sfoobar=yes                    ;;
    -  ) [ $OPTIND -ge 1 ] && optind=$(expr $OPTIND - 1 ) || optind=$OPTIND
         eval OPTION="\$$optind"
         OPTARG=$(echo $OPTION | cut -d'=' -f2)
         OPTION=$(echo $OPTION | cut -d'=' -f1)
         case $OPTION in
             --foo       ) lfoo=yes                       ;;
             --bar       ) lbar=yes                       ;;
             --foobar    ) lfoobar=yes                    ;;
             --barfoo    ) lbarfoo=yes                    ;;
             --help      ) _usage                         ;;
             --arguments ) larguments=yes;lARG="$OPTARG"  ;; 
             * )  _usage " Long: >>>>>>>> invalide options (long) " ;;
         esac
       OPTIND=1
       shift
      ;;
    ? )  _usage "Short: >>>>>>>> invalide options (short) "  ;;
  esac
done
##################################################################
echo "----------------------------------------------------------"
echo "RESULT short-foo      : $sfoo                                 long-foo      : $lfoo"
echo "RESULT short-bar      : $sbar                                 long-bar      : $lbar"
echo "RESULT short-foobar   : $sfoobar                                 long-foobar   : $lfoobar"
echo "RESULT short-barfoo   : $sbarfoo                                 long-barfoo   : $lbarfoo"
echo "RESULT short-arguments: $sarguments  with Argument = \"$sARG\"        long-arguments: $larguments and $lARG"
share|edit
Was this post useful to you?     

Wednesday, February 29, 2012

IInterest'Blog

IInterest'Blog
← 常用的CSS3文字特效HTML5可视化编辑器[5] →
UC浏览器web开发实践
Posted on 2011年07月20日 by Bell 1,233 views
最近一直在做移动互联网项目,基本上都是针对UC浏览器的开发,这里总结下各种实践经验,罗列一些基于UC浏览器7.7以上版本的开发技巧。

CSS支持情况(数据来源:官方文档)

↑点击浏览

UC浏览器自定义特殊标签及属性
直连方式:
ext:a:
使用方法(下同):
iinterest

PS:如果是ext:xxx:格式也可以在地址栏中使用(下同)

服务器中转:
ext:e:

webkit内核渲染:
ext:webkit:

返回主页:
ext:startpage

刷新:
ext:refresh

前进:
ext:forward

后退:
ext:back

拨打电话:
ext:tel/10010

发送短信:
ext:sms/内容|电话号码|

书签:
ext:bookmark

上传书签:
ext:upload_favo

本地帮助:
ext:help

短信推荐uc浏览器:
ext:friend

在新窗口中打开url
ext:wo:

实践中的一些问题(持续更新,2011.11.4)
10.CSS文字颜色,使用缩写时会出现无法识别的情况。
9.背景色跟文字颜色相同时,会自动调整文字颜色为反选色。
8.ucweb 8.0 进入阅读模式后无法载入背景图片。
7.ucweb 7.8 iphone版无法识别itms://跳转苹果应用商店…严重bug![2011.8.3]
6.为块级元素添加color会出现同色边框(s40平台)
5.CSS特殊性计算有问题(个别平台)
4.同向浮动的两个元素(float:left),第二个元素内如果嵌套有块级元素,那么这个元素的同向内边距会失效(padding-left)。这时建议尽量使用外边距(margin-left)。(个别平台)
3.不支持负边距(个别平台)
2.遇到无法识别的CSS时会停止对“错误”及以后的CSS解析,所以如果要用到hack最好放在末尾(全平台)
1.DOCTYPE 只支持 DTD XHTML Mobile 1.0(全平台)

Sunday, February 26, 2012

Prototype: Bus Pirate BPv3 | Dangerous Prototypes

Prototype: Bus Pirate BPv3 | Dangerous Prototypes

Prototype: Bus Pirate BPv3

in BP v3, Bus Pirate, Prototypes by Ian | 16 comments

sideiii.450

UPDATE: v3b is the latest Bus Pirate revision, read about the changes here.

BPv3 is the latest hacking multi-tool from the Bus Pirate project. It connects to a USB port and interacts with electronics through a simple terminal interface.

stack-exampleUse it to see how much of your private information is stored on smartcard SIM chips. Explore the Wii Nunchuck over the I2C bus like Johnny Lee. Read and write EEPROM chips in consumer electronics at any voltage. Check out all the existing chip demonstrations.

BPv3 has features an intrepid hardware hacker might need to prototype their next great creation:

  • Talk to 1-wire, I2C, UART (async serial), SPI, JTAG, MIDI, LCDs, PC keyboards, and a ton of generic serial devices from a terminal.
  • Scriptable from Python, Perl, etc.
  • 0-40MHz frequency counter, 0-4MHz pulse-width modulator.
  • 0-6volt measurement probe.
  • 3.3volt and 5volt power supplies with reset.
  • On-board pull-up resistors for multi-voltage interfacing.
  • Address scanners, chip dumpers, and other helpful macros.
  • USB interface, power. USB firmware updates.
  • Translations (currently Spanish and Italian, add your own).

Get an assembled red BPv3 for $30, including worldwide shipping, thanks to Seeed Studio. You can also grab the plans from the Bus Pirate project page and build your own.

This article introduces BPv3, the latest hardware from the Bus Pirate project. We’ll look at the history of the design, share our experience organizing the production of Bus Pirate v2go, and talk about issues that influenced hardware version 3.

History of the Bus Pirate universal serial interface

We made the first Bus Pirate to deal with a particularly difficult chip that didn’t behave as expected. We wanted to send SPI commands through a serial terminal so we could test the chip without compiling a firmware to implement each small change.

v0.ii.450

Bus Pirate V0 was based on an USB-enabled PIC 18F2550 microcontroller. It operated at 5volts only, and didn’t have on-board power supplies. V0 was published on a personal blog under the GPL, sometime around 2004. Along with some very poor soldering, you can see the first use of the Bus Pirate name etched into the copper.

v0a.450

Bus Pirate V0a upgraded to a 16bit PIC 24FJ64GA002, but traded USB for a serial interface. This version also added 3.3volt and 5volt power supplies, and two 3.3volt software-controlled pull-up resistors.

Microchip’s new low-pincount PICs are perfect for the Bus Pirate because of a feature called peripheral pin select. Many microcontrollers have hard-wired pin assignments, but PPS assigns some features to any pins we like. The PIC 24FJ is a better choice than the dsPIC33-series because the pins can source/sink more current (20mA vs 4mA).

We used a rare and expensive RS232 transceiver from our parts box in this design because it was intended for ‘in house’ use. We released this design into the public domain, and Hack a Day later published an article about it as a stop-gap when other content wasn’t ready.

v1.450

Bus Pirate V1a was another serial interface design, but this version used mostly surface mount parts. We replaced the expensive RS232 transceiver with a cheap, common SMD version. The power supplies were upgraded to 800mA switchable regulators that can be reset from within the terminal. V1a ditched the software controlled pull-up resistors, and used jumpers to connect pull-ups to the four bus pins. This version added voltage monitoring probes using extra analog to digital converter pins on the PIC.

The v1a Bus Pirate was also released into the public domain, and we wrote an article about it that was published on Hack a Day. Fundamental logic revised the v1 design and released a through-hole serial port Bus Pirate kit (also public domain). You might still be able to buy the kit for $20.

v2-ssii.450

Bus Pirate V2 is the current king of the Bus Pirate designs, it’s the first of the modern 16bit designs to have a USB interface (via an FTDI serial->USB chip). V2a was an early revision (left), v2go was the final version of the V2 family (right). V2 swaps in smaller, cheaper, and awesomer power supplies (MIC5205) recommended by Nate at SparkFun. We finally brought software switchable pull-up resistors to all four main bus pins via aCD4066 IC.

The Bus Pirate project was approached by a company that wanted to sell the v2 design, but complications and time constraints got in the way. Instead, we ran a group preorderas a fundraiser for Hack a Day, and got some experience with the manufacturing process.

Almost 1000 Bus Pirates sold in 10 days, with all proceeds going to Mahalo, the company that operates Hack a Day. So many sold that we had supply problems, Seeed Studiocouldn’t find enough PIC 24FJ64GA002-SO to fill the order.

sideiii.450

BPv3 is designed to address supply and manufacturing problems encountered during the v2go preorder. v2go would have been the final Bus Pirate, but we learned so much during manufacturing that we wanted to apply it to an updated design. For V3 we did a full, scratch redesign of the PCB that went through two revisions.

If you’ve got a Bus Pirate v2go, don’t worry because it’s functionally equivalent to v3. V2go and V3 will even bootload and run the same firmware. In retrospect, v2go was a cute-but-poor version choice. Where do you go from there? v2go+1=? We chose V3.

Updates to BPv3

bpv3cct.450

Click here for a full size schematic image [PNG]. The schematic and PCB were designed with the free version of Cadsoft Eagle, the latest design files are on the project page at Google Code.

The basic Bus Pirate design has been covered extensively at Hack a Day, we won’t duplicate that here. Refer to these fantastic Bus Pirate articles: v2, v1, v0.

Resolve manufacturing issues

compare.450

Hack a Day’s Bus Pirate preorder had to be split due to a shortage of SOIC-size PIC microcontrollers. BPv3 uses the smaller, more common SSOP-size (IC1). The smaller chip also allowed a reduction in PCB size and a few other tweaks.

The programming pins on v2 were swapped from the normal PICkit2 order. Seeed had to use an adapter to program the v2go Bus Pirates, BPv3 has the correct pin order for easier manufacturing. Bootloaders for V2go and v3 are not interchangeable because of this modification.

Manufactured BPv3s will be programmed with the latest bootloader and firmware, which contains a self-test for better quality control.

Circuit updates

FTDI.450

The FTDI 232R USB->serial converter’s (IC2) IO pins are now driven by the main supply regulator, which is probably better than running it from the internal regulator as in v2go. The FTDI enable pin could be connected to the 3.3volt supply regulator (VR2) enable to make a fully USB sleep compliant device, but we didn’t because the routing was too complicated.

We added a 0.1uF capacitor (C6) to decouple the VCCIO supply pin, the datasheet wasn’t clear if this is required but it’s probably best practice.

The header (ST) that taps the serial connection between the FTDI232R (IC2) and the PIC (IC1) was removed. A poll of developers found that none had ever used it, and the routing is cleaner without it.

solder-bridge.450

The interior connection between two adjacent ground pins on IC3 was removed because so many people thought it was a solder bridge. (It’s not.)

Tweaks

bpv3-stripiii

We tweaked part placement during the PCB redesign. The USB jack (J1) is centered. The CD4066 (IC3) is rotated for better clearance around the IO header.

We moved the USB activity LED to the top of the PCB. LED labels are bolder, easier to read.

Traces that carry power are fatter, and have bigger vias. We used wider 12mil trace/space wherever possible to improve PCB yield. The ground plane is reinforced with more and larger vias in important areas.

io.450

The tighter placement required us to swap the 3.3volt and ADC pins on the I/O header. This is easier to route, and the ribbon cable pinout is more logical: ADC-5.0-3.3-GND.

PCB

BusPirate-v3e-renderii.450

We used the freeware version of Cadsoft Eagle to make the schematic and PCB. Download the latest designs and firmware from the project Google Code page.

The PCB is small and tightly packed. It’s a challenging board that takes us an hour to solder from memory. Seeed Studio sells the extra PCBs from our order.

Partslist

brdii.450

Click for a full size placement image [PNG].

NameValue (size)Notes
IC1PIC24J64GA002-SS (SSOP)Changed to SSOP
IC2FT232RL (SSOP)
IC3CD4066D (SOIC-N)
C1-60.1uF capacitor (0805)Added C6
C20-2410uF tantalum capacitor (SMC-A)
ICSP, IO0.1″ pin header (3×05)
J1USB MINI-B (SMD)J2 renamed J1
L11000ma+ ferrite bead (0805)
LED1-4LED (0805)
R12000 ohm resistor (0805)
R2,31100 ohm resistor (0805)R30 renamed R2
R10-17, 19-2310000 ohm resistor (0805)Removed R18
R31,32390 ohm resistor (0805)
VR2,3MIC5205 3.3volt regulator (SOT23-5)
VR4MIC5205 5volt regulator (SOT23-5)

Taking it further

UPDATE: v3b is the latest Bus Pirate revision, read about the changes here.

Check the Bus Pirate manual for usage examples, pin diagrams, connection tables, syntax guides, and more.

We’re happy with the current hardware features. Future updates will focus on improving the firmware, and adding features via the firmware and break-out boards.

You can discuss the project in the forum, or join us on the Google Code Bus Pirate project.

Get one!

Get an assembled red BPv3 for $30, including worldwide shipping, thanks to Seeed Studio. You can also grab the plans from the Bus Pirate project page and build your own.

Producing the Bus Pirate

Seeed Studio made it really easy to sell a project without worrying about a website, billing, shipping, etc. We’re working with them again on BPv3 and the #twatch ethernet LCD backpack.

bpv3-take1.250To manufacture a project, you need to submit design files, a part list, and a firmware file.

We design circuit boards in Cadsoft Eagle andcreate gerber design files, but many board houses now accept Eagle .brd files too. We send the gerbers to a board house and test the PCB. We order revisions and test again, if required.

Assembling a part list can be fairly involved. At minimum, we specify part type, value, and size. Elaborate as much as possible on critical values or custom parts. For a 10uF capacitor, what type and how many volts max? If a 1% tolerance resistor is required, it needs to be specified.

Our best advise is to design with common parts. Check DigiKey and Mouser (or better,Octopart), be sure you can get a few hundred of your critical part from several suppliers. Check the supply of any specific microcontroller or IC that could hold up production.

v2go-250Seeed was able to locate 300 PIC 24FJ64GA002-SO microcontrollers prior to the Hack a Day preorder. When orders took off, the initial 300 were gone within 48 hours. In the end, nearly 1000 Bus Pirates were sold. The extra 700 PICs took almost 2 months to source.

It’s important to plan for production programming. The Bus Pirate uses a two part firmware, a bootloader and a main program. The normal programing method is to burn the bootloader and then upload a main program over USB. This is too slow for manufacturing, so we created a complete, bootloaded PIC firmware dump that combines both parts into a single image.

When manufacturing starts, be prepared for issues that hardly ever happen in a single chip, but occur quite frequently in 1000. Around 15% of v2gos failed initial quality control tests. They wouldn’t connect to the bootloader at the default speed (115200bps). The bug turned out to be a baud rate setting that wasn’t precise enough due to the inaccuracy of the internal crystal. The remaining boards worked after reducing the bootloader speed on the PC to 9600bps.

The members of the Bus Pirate project team learned a lot producing v2go with Seeed Studio. It wasn’t without problems, but we used that experience to refine the hardware design. We hope this background information helps you produce your first widget, be sure to let us know when it debuts.

Get one!

Get an assembled red BPv3 for $30, including worldwide shipping, from Seeed Studio. You can also grab the plans from the Bus Pirate project page and build your own.

sideiii.450

This entry was posted in BP v3, Bus Pirate, Prototypes and tagged ,, .

Comments

  1. Merve says:

    I only *just* (2 days ago) signed up for one on the google spreadsheet preorder notification. Will that go through or should I put another order in through the seedstudio page?

  2. Ian says:

    Go ahead and buy it from Seeed. The notification should go out to everyone that signed up in a few days, it’ll just contain a link to the Seeed page and a notice that the mailing list has been destroyed.

  3. Mio says:

    Awesome. Ordered.

  4. chipres says:

    the postage expensive then the actual Bus Pirate v3 :(

  5. Merve says:

    When I look it says:
    Registered Air Parcel – $2.85. That’s to Australia, there can’t be many places further away.

  6. Ian says:

    @chipres – what option did you choose? Seeed sends worldwide for $2.85, so the Bus Pirate should be $30, shipped.

  7. chipres says:

    i press estimate shipping rates DHL Rates (Shipping to MV (1 x 33.00g))

  8. chipres says:

    preoder $29.83 USD
    thanks

  9. Muris says:

    I just got my Bus Pirate v3 !
    Woohooo!

  10. Pedro says:

    I want to find out the master in a I2C system that includes four chips. Three are inside a device that I can not open, in the device outside, a PIC microcontroller is being used. I have tapped the bus lines and have all the chips IDs. Can I use this device and is there any documentation before ordring?
    Thanks

    • Ian says:

      I’m sorry, I don’t think the Bus Pirate will do this.

      • AndThen says:

        the master will drive the clock line, via a resistor wouldn’t it?
        i2c bus could be multi master also, in that case it’s not easy.

        In theory you need taps at each chip, and a center tap. 4 fast trigger capture, and some flavor of logic (nOR?)

        Could always start lifting potential clock pins =D

  11. Pedro says:

    Would the system continue to work if one of the slaves does not acknowledge or is out of the loop?

    • AndThen says:

      It’s hard to say what would happen, could explode I guess. If you lift/disconnect all the clock pins it’s about as safe as i can think to make it. Maybe tie SDA low, if my memory serves me well, ACK is a high bit.

      So with all the clocks disconnected only a master will have a signal, and with data low it won’t read an ACK and so will either spin loops, error, or take over the world. Depending on the coders whims.

  12. Pedro says:

    That is a very smart idea. I will try that and post the results. Thanks again.

Leave a Comment

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes:

Notify me of followup comments via e-mail. You can also subscribe without commenting.