Wednesday, September 15, 2010

Command-Line Conventions

command的參數傳遞可分為兩種,以 "-" 加上一個單一字母或 "--" 加上一字串。
例如:如下兩個參數對於command來說皆相同。
-h
--help

Monday, September 13, 2010

CAN-USB/2

Driver install (Linux kernel 2.6)
% cd socketcan-trunk-r1110/kernel/2.6
% make
% sudo make modules_install
% sudo /sbin/depmod -a

Check installation
% ls /sys/class/net/

There should be have an entry "can0".

Thursday, September 9, 2010

Socket CAN

Socket CAN uses the Berkeley socket API, the Linux  network stack and implements the CAN device drivers as network interface.
一般皆使用Character-device方式實作CAN driver.
若以Character-device實作CAN device driver,其限制:只有一個Process可以使用;更換不同的CAN Controller時,可能需要動到App。
以Socket CAN的方式操作,同時有多個Process可以存取CAN device,且可以同時Listening相同ID的訊息。以Character-device的方式並非無法達成,只是成品看起來會很醜,而且不好用。
對於Application來說,透過一個已定義好的Abstraction layer存取device。和硬體相關的介面也有定義,所以只要實作這些API即可。

Sunday, August 15, 2010

Return a function pointer

Without a pre-defined function pointer type

float (*GetPtr1(const char opCode))(float, float) {    if(opCode == '+')       return &Plus;    else       return &Minus; // default if invalid operator was passed }

參考來源:

"float (*GetPtr1(const char opCode))(float, float)"
- The Function Pointer Tutorials - Syntax (在「Google 網頁註解」中檢視)

Sunday, October 12, 2008

AD converter: TI ADS1110

AD reference voltage不需由外部提供. 2.048V
Analog input voltage: ±2.048V (V+in - V-in) ( -2.048 ~ +2.048V )
目前的使用方式, V-in直接接地, analog input voltage的範圍: 0 ~ +2.048V
精確度由16-bits降為15-bits.



Sunday, August 3, 2008

Mutex


Priority arrangement
HH: RS485 Rx handler
H: Voltage control
M: Peripheral
L: SMR


void
COMM_Init()
{
Create mutex for RS485 driver.
Create a task, named RS485 Rx Handler.
}


bool
RS485_TxHandler(byte *pPacket, bool waitSlave, portTypeTick delay )
{
if ( mutex is not available )
{
delay;
if ( mutex is still not available ) return false;
}

if ( waitSlave ) resume task, RS485 Rx Handler.
......
.....
other codes.
....

release the mutex.
}


void
Task_RS485_RxHandler
()
{
byte c;
Suspend itselt;

for(;;)
{
Delay 5ms.
while( RS485_GetByte( &c, delay_2ms ) )
{
if ( Get a legal RS485 Packet ) {
Signal semaphore, SEM_RS485_Arrive_Packet;
break;
}
}
Suspend itself.
}
}


Binary Semaphore : 用於Task之間的同步
Mutex : (MUTual EXclusion semaphores), are used by tasks to gain exclusive access to resources. A mutex is used by App to reduce the priority inversion problem.

Thursday, June 19, 2008

ColdFire 5208EVBe

uClinux has builed in.

Console connection:
Baudrate: 115200bps
Port: Terminal UART0