Index: trunk/kernel/devices/dev_txt.c
===================================================================
--- trunk/kernel/devices/dev_txt.c	(revision 647)
+++ trunk/kernel/devices/dev_txt.c	(revision 657)
@@ -133,40 +133,4 @@
 }  // end dev_txt_init()
 
-//////////////////////////////////////////////////////////////////////////////////
-// This static function is called by dev_txt_read(), dev_txt_write() functions.
-////////////////////////////////////i/////////////////////////////////////////////
-static error_t dev_txt_access( uint32_t   type,
-                               uint32_t   channel,
-                               char     * buffer,
-                               uint32_t   count )
-{
-    xptr_t     dev_xp;
-    thread_t * this = CURRENT_THREAD;
-
-    // check channel argument
-    assert( (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" );
-
-    // get extended pointer on remote TXT chdev descriptor
-    if( type == TXT_WRITE )  dev_xp = chdev_dir.txt_tx[channel];
-    else                     dev_xp = chdev_dir.txt_rx[channel];
-
-    assert( (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" );
-
-    // register command in calling thread descriptor
-    this->txt_cmd.dev_xp  = dev_xp;
-    this->txt_cmd.type    = type;
-    this->txt_cmd.buf_xp  = XPTR( local_cxy , buffer );
-    this->txt_cmd.count   = count;
-
-    // register client thread in waiting queue, activate server thread
-    // block client thread on THREAD_BLOCKED_IO and deschedule.
-    // it is re-activated by the ISR signaling IO operation completion.
-    chdev_register_command( dev_xp );
-
-    // return I/O operation status from calling thread descriptor
-    return this->txt_cmd.error;
-
-}  // end dev_txt_access()
-
 /////////////////////////////////////////
 error_t dev_txt_write( uint32_t   channel,
@@ -180,6 +144,7 @@
 #endif
 
+    thread_t * this = CURRENT_THREAD;
+
 #if DEBUG_DEV_TXT_TX
-thread_t * this  = CURRENT_THREAD;
 uint32_t   cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEV_TXT_TX < cycle )
@@ -188,14 +153,20 @@
 #endif
 
+// check channel argument
+assert( (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" );
+
+    // get pointers on chdev
+    xptr_t    dev_xp  = chdev_dir.txt_tx[channel];
+    cxy_t     dev_cxy = GET_CXY( dev_xp );
+    chdev_t * dev_ptr = GET_PTR( dev_xp );
+
+// check dev_xp 
+assert( (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" );
+
     // If we use MTTY (vci_multi_tty), we do a synchronous write on TXT[0]
     // If we use TTY  (vci_tty_tsar), we do a standard asynchronous write
     // TODO this is not very clean ... [AG]
 
-    // get pointers on chdev
-    xptr_t dev_xp = chdev_dir.txt_tx[0];
-    cxy_t     dev_cxy = GET_CXY( dev_xp );
-    chdev_t * dev_ptr = GET_PTR( dev_xp );
-
-    if( dev_ptr->impl == IMPL_TXT_MTY )
+    if( dev_ptr->impl == IMPL_TXT_MTY )  
     {
         // get driver command function
@@ -216,6 +187,17 @@
     else
     {
-        // register command in chdev queue for an asynchronous access
-        error = dev_txt_access( TXT_WRITE , channel , buffer , count );
+        // register command in calling thread descriptor
+        this->txt_cmd.dev_xp  = dev_xp;
+        this->txt_cmd.type    = TXT_WRITE;
+        this->txt_cmd.buf_xp  = XPTR( local_cxy , buffer );
+        this->txt_cmd.count   = count;
+
+        // register client thread in waiting queue, activate server thread
+        // block client thread on THREAD_BLOCKED_IO and deschedule.
+        // it is re-activated by the ISR signaling IO operation completion.
+        chdev_register_command( dev_xp );
+
+        // get I/O operation status from calling thread descriptor
+        error = this->txt_cmd.error;
 
         if( error )
@@ -251,6 +233,7 @@
 #endif
 
+    thread_t * this = CURRENT_THREAD;
+
 #if DEBUG_DEV_TXT_RX
-thread_t * this  = CURRENT_THREAD;
 uint32_t   cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEV_TXT_RX < cycle )
@@ -259,11 +242,31 @@
 #endif
 
-    // register command in chdev queue for an asynchronous access
-    error = dev_txt_access( TXT_READ , channel , buffer , 1 );
+// check channel argument
+assert( (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" );
+
+    // get pointers on chdev
+    xptr_t    dev_xp  = chdev_dir.txt_rx[channel];
+
+// check dev_xp 
+assert( (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" );
+
+    // register command in calling thread descriptor
+    this->txt_cmd.dev_xp  = dev_xp;
+    this->txt_cmd.type    = TXT_READ;
+    this->txt_cmd.buf_xp  = XPTR( local_cxy , buffer );
+    this->txt_cmd.count   = 1;
+
+    // register client thread in waiting queue, activate server thread
+    // block client thread on THREAD_BLOCKED_IO and deschedule.
+    // it is re-activated by the ISR signaling IO operation completion.
+    chdev_register_command( dev_xp );
+
+    // get I/O operation status from calling thread descriptor
+    error = this->txt_cmd.error;
 
     if( error )
     {
-        printk("\n[ERROR] in %s : cannot get character / cycle %d\n",
-        __FUNCTION__, (uint32_t)hal_get_cycles() );
+         printk("\n[ERROR] in %s : cannot write string %s / cycle %d\n",
+         __FUNCTION__, buffer, (uint32_t)hal_get_cycles() );
     }
 
