]> rtime.felk.cvut.cz Git - CanFestival-3.git/commitdiff
kerneltest updated for the new api
authorgreg <greg>
Mon, 2 Jun 2008 06:52:06 +0000 (06:52 +0000)
committergreg <greg>
Mon, 2 Jun 2008 06:52:06 +0000 (06:52 +0000)
configure
drivers/timers_kernel/timers_kernel.c
drivers/unix/unix.c
examples/kerneltest/TestMasterSlave.c
examples/kerneltest/console/console.c
examples/kerneltest/kernel_module.c
src/symbols.c

index 3ccfe55da68211f083a2461a86b3b67a365d619e..b7f971cb4e5b0b7549f0385ead41b2e7519f83f3 100755 (executable)
--- a/configure
+++ b/configure
@@ -161,7 +161,7 @@ while [ $# -ge 1 ]; do
                echo    "                 see http://www.ocera.org/download/components/WP7/lincan-0.3.3.html"
                echo    "               \"can4linux\" can4linux driver"
                echo    "                 see http://www.port.de/engl/canprod/hw_can4linux.html"
-               echo    " --timers=foo  Use 'foo' as TIMERS driver (can be 'unix', 'xeno' or 'kernel')"
+               echo    " --timers=foo  Use 'foo' as TIMERS driver (can be 'unix', 'xeno', 'rtai' or 'kernel')"
                echo    " --wx=foo  force result of WxWidgets detection (0 or 1)"
                echo    " --disable-dll Disable run-time dynamic linking of can, led and nvram drivers"
                echo    " --enable-lss  Enable the LSS services"
index 58a3bbf3ea09103b310d0b7926ec3b7297e7fc49..0bbe2c8571d144012a7180360a43f004bdc9671c 100644 (file)
@@ -36,6 +36,15 @@ static TIMEVAL last_time_read,
        last_occured_alarm,
        last_alarm_set;
 
+void TimerInit(void)
+{
+       /* only used in realtime apps */
+}
+
+void TimerCleanup(void)
+{
+       /* only used in realtime apps */
+}
 
 void EnterMutex(void)
 {
@@ -71,10 +80,11 @@ void StartTimerLoop(TimerCallback_t init_callback)
        LeaveMutex();
 }
 
-void StopTimerLoop(void)
+void StopTimerLoop(TimerCallback_t exitfunction)
 {
        EnterMutex();
        del_timer (&timer);
+       exitfunction(NULL,0);
        LeaveMutex();
 }
 
@@ -99,7 +109,7 @@ void CreateReceiveTask(CAN_PORT port, TASK_HANDLE *Thread, void* ReceiveLoopPtr)
        *Thread = kthread_run(ReceiveLoopPtr, port, "canReceiveLoop");
 }
 
-void WaitReceiveTaskEnd(TASK_HANDLE Thread)
+void WaitReceiveTaskEnd(TASK_HANDLE *Thread)
 {
-       force_sig (SIGTERM, Thread);
+       force_sig (SIGTERM, *Thread);
 }
index 216ac6d7ba267bdb991d624f10ef6d162beb26f3..7678874086e5edb4947a552c0b5153c1ec927d8c 100644 (file)
@@ -245,4 +245,5 @@ UNS8 canChangeBaudRate(CAN_PORT port, char* baud)
 EXPORT_SYMBOL (canOpen);
 EXPORT_SYMBOL (canClose);
 EXPORT_SYMBOL (canSend);
+EXPORT_SYMBOL (canChangeBaudRate);
 #endif
index b28dea847e45851defca8f693ebfb8aff271df5d..609f4e409c8913bff70395b4ebd63b575ca1d676 100644 (file)
@@ -35,8 +35,20 @@ static void InitNodes(CO_Data* d, UNS32 id)
        }
 }
 
+/***************************  EXIT  *****************************************/
+void Exit(CO_Data* d, UNS32 id)
+{
+       masterSendNMTstateChange(&TestMaster_Data, 0x02, NMT_Reset_Node);    
+
+       //Stop master
+       setState(&TestMaster_Data, Stopped);
+}
+
+
 int TestMasterSlave_start (void)
 {
+       TimerInit();
+
        if(strcmp(SlaveBoard.baudrate, "none")){
                
                TestSlave_Data.heartbeatError = TestSlave_heartbeatError;
@@ -83,21 +95,13 @@ void TestMasterSlave_stop (void)
 {
        eprintf("Finishing.\n");
        
-       EnterMutex();
-       masterSendNMTstateChange (&TestMaster_Data, 0x02, NMT_Reset_Node);
-       LeaveMutex();
-       
-       // Stop master
-       EnterMutex();
-       setState(&TestMaster_Data, Stopped);
-       LeaveMutex();
-       
        // Stop timer thread
-       StopTimerLoop();
+       StopTimerLoop(&Exit);
        
        // Close CAN devices (and can threads)
        if(strcmp(SlaveBoard.baudrate, "none")) canClose(&TestSlave_Data);
        if(strcmp(MasterBoard.baudrate, "none")) canClose(&TestMaster_Data);
 
+       TimerCleanup();
        eprintf("End.\n");
 }
index 9f36beea2a305678df8e0afad046f4205a442715..7ed6011e4798ee1cad8f8596a90f3901ade387c4 100644 (file)
@@ -12,7 +12,7 @@ void showhelp(void) {
        printf("\nCanFestival kernel test example console\n\n");
 
        printf("start - start example\n");
-       printf("end   - end example\n");
+       printf("stop  - stop example\n");
        printf("quit  - quit console\n");
        printf("\n");
 }
@@ -42,7 +42,7 @@ int main(int argc,char *argv[])
                if (strcmp(command,"start") == 0)
                        cmd = CMD_START;
                
-               else if (strcmp(command,"end") == 0)
+               else if (strcmp(command,"stop") == 0)
                        cmd = CMD_STOP;
                
                else if (strcmp(command,"quit") == 0)
index 520c4378c1e8d430a8ca5b142161bb8b3b3736ba..40759fa98be351a31233902dabe75c612da3a02a 100644 (file)
@@ -17,6 +17,9 @@ static struct task_struct *thread_start_p, *thread_stop_p;
 static DECLARE_MUTEX (canftest_mutex);
 static int canftest_stopped = 1;
 
+int thread_start (void* data);
+int thread_stop (void* data);
+
 // handler processing write() requests from user-space
 ssize_t canftest_write(struct file *filp, const char __user *buf, size_t count,
                       loff_t *f_pos)
@@ -30,15 +33,33 @@ ssize_t canftest_write(struct file *filp, const char __user *buf, size_t count,
        // process integer as command
        switch (cmd) {
                case CMD_START:
+                       if (!canftest_stopped) break;
+                       thread_start_p = kthread_create (thread_start, NULL, "canftest_start");
+
+                       if (PTR_ERR(thread_start_p) == -ENOMEM) {
+                               printk(KERN_WARNING "canftest: error creating start thread\n");
+                               return -ENOMEM;
+                       }
+
                        wake_up_process (thread_start_p);
                        break;
+
                case CMD_STOP:
                        if (canftest_stopped) break;
+                       thread_stop_p = kthread_create (thread_stop, NULL, "canftest_stop");
+
+                       if (PTR_ERR(thread_stop_p) == -ENOMEM) {
+                               printk(KERN_WARNING "canftest: error creating stop thread\n");
+                               return -ENOMEM;
+                       }
+
                        wake_up_process (thread_stop_p);
                        break;
+
                // ignore new line character
                case 10:
                        break;
+
                default:
                        printk("canftest: bad command %d\n", cmd);
                        break;
@@ -114,14 +135,6 @@ int init_module(void)
                return ret;
        }
 
-       thread_start_p = kthread_create (thread_start, NULL, "canftest_start");
-       thread_stop_p = kthread_create (thread_stop, NULL, "canftest_stop");
-       
-       if (PTR_ERR(thread_start_p) == -ENOMEM || PTR_ERR(thread_stop_p) == -ENOMEM) {
-               printk(KERN_WARNING "canftest: error creating threads\n");
-               return -ENOMEM;
-       }
-
        return 0;
 }
 
index d4f4b0ae3187de7ed6b4392727d7a600647f2765..0b9ae3f7d27f193547953d566329abbb6685b991 100644 (file)
@@ -124,7 +124,9 @@ EXPORT_SYMBOL (getElapsedTime);
 // timers_driver.h
 EXPORT_SYMBOL (EnterMutex);
 EXPORT_SYMBOL (LeaveMutex);
-EXPORT_SYMBOL (WaitReceiveTaskEnd);
+EXPORT_SYMBOL (TimerInit);
+EXPORT_SYMBOL (TimerCleanup);
 EXPORT_SYMBOL (StartTimerLoop);
 EXPORT_SYMBOL (StopTimerLoop);
 EXPORT_SYMBOL (CreateReceiveTask);
+EXPORT_SYMBOL (WaitReceiveTaskEnd);