2012年8月4日 星期六

小老婆 SYM T1

P1070099

前陣子收到大潤發寄來的DM,有一份全部都是在賣機車的,

現在的機車真的是滿貴的,但也發現一台檔車超帥的,

跟了我10幾年的YAMAHA風光雖然還不至於要報廢的階段,

但還是忍不住想完成年輕時的夢想,

所以,也就有了這篇文章,

在買檔車之前,也survey了幾台國產的檔車,

不過最對胃的還是SYM的T1,

在入手前,先跟同事借了野狼練習了半小時左右,

隔幾天就去跟摩托車店的老闆訂車了,

剛開始由於對離合器的控制還是處於很陌生的階段,

而且有空練習的時間也不多,所以剛開始常常在紅燈起步的時候熄火,

更別說是在上坡的起步,曾遇到有個路口綠燈只有10幾秒,

我花了4次才成功的穿越馬路…@@

不過經過幾次的練習之後,現在都已經不會熄火啦~

P1070094

 

P1070118

騎檔車其實沒啥優點,就是帥而已…

缺點很多,沒置物空間、迴轉半徑大、下雨天更是麻煩,

不過這些缺點是可以克服啦~T1只有150cc,所以起步很慢,

尾速也是很慢…很適合我這種老人阿…

無論如何,騎檔車的樂趣真的要親身體驗才會懂啦!

2012年2月21日 星期二

Hex to string

int CharToHex(const char ch)
{
const char Hex[] = "0123456789ABCDEF";
for (int n = 0; Hex[n]; ++n)
{
   if (ch == Hex[n])
   {
       return n;
   }
}
return 0;
}

UINT64 StringToHex(const char* c)
{
UINT64 l = 0;
for (int n = 0; c[n]; ++c)
{
   l = l * 16 + CharToHex(c[n]);
}
return l;
}

2012年2月1日 星期三

轉貼 VxWorks thread同步(使用Semaphore)

/* includes */
#include "vxWorks.h"
#include "taskLib.h"
#include "semLib.h"
#include "stdio.h"

/* function prototypes */
void taskOne(void);
void taskTwo(void);

/* globals */
#define ITER 10
SEM_ID semBinary;
int global = 0;

void binary(void)
{
int taskIdOne, taskIdTwo;

/* create semaphore with semaphore available and queue tasks on FIFO basis */
semBinary = semBCreate(SEM_Q_FIFO, SEM_FULL);

/* Note 1: lock the semaphore for scheduling purposes */
semTake(semBinary,WAIT_FOREVER);

/* spawn the two tasks */
taskIdOne = taskSpawn("t1",90,0x100,2000,(FUNCPTR)taskOne,0,0,0,0,0,0,0,0,0,0);
taskIdTwo = taskSpawn("t2",90,0x100,2000,(FUNCPTR)taskTwo,0,0,0,0,0,0,0,0,0,0);
}


void taskOne(void)
{
int i;
for (i=0; i < ITER; i++)
 {
 semTake(semBinary,WAIT_FOREVER); /* wait indefinitely for semaphore */
 printf("I am taskOne and global = %d......................\n", ++global);
 semGive(semBinary); /* give up semaphore */
 } 
}

void taskTwo(void)
{
int i;
semGive(semBinary); /* Note 2: give up semaphore(a scheduling fix) */
for (i=0; i < ITER; i++)
 {
 semTake(semBinary,WAIT_FOREVER); /* wait indefinitely for semaphore */
 printf("I am taskTwo and global = %d----------------------\n", --global);
 semGive(semBinary); /* give up semaphore */
 } 
}