This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

NDK telnet escape function



Hello, my project is bases on:

- Concerto F28M36 (master / CortexM3)

- CCS5.5

- TI-RTOS 1.21, including SYS/BIOS 6.37, NDK 2.23

The TI-RTOS including SYS/BIOS and NDK is all configured statically using XGCONF.

The project uses a telnet server. I realized that with a static Telnet instance inside XGCONF (under NDK->Application Layer->Telnet) and basically just used the example from

C:\ti\tirtos_1_21_00_09\products\ndk_2_23_01_01\packages\ti\ndk\tools\console\console.c

while renaming the symbols/identifiers in that file.

This works fine. I added a new telnet command "trace" that enters a loop to continuously send trace data over the telnet link (approx 1 kHz). Now I need to stop that cyclic emission on escape. This is where I have a problem: I obviously cannot use ConGetCh, since this is a blocking function. I tried to start a new task from the telnet task and call ConGetCh from there, but it crashes the telnet server. The new task's priority is OS_TASKPRILOW, which equals 3 by standard (lowest prio of the project). The telnet task is OS_TASKPRINORM, which equals 5 (second lowest prio of the project).

The new task calls ConGetCh in an endless loop and does not call Task_sleep, since it is the lowest priority task. The telnet task calls Task_Sleep(1ms) to allow execution of the ConGetCh task. When ConGetCh returns an escape char, the new task indicates this to the telnet task and exits (by returning).

Question 1) From a conceptional point of view, is what I'm trying to do possible ? I only use standard code, coming from the example file console.c. Is the NDK telnet module capable of receiving a message while sending frames ?

Question 2) If basically it's possible, what would be the proper way to do this.

Thanks a lot in advance.

Best regards,

Frank

  • Frank,

    I will have to check with an expert for some help with this.  But just to be clear… did you implement this and get it working?  And are you just checking that it should be OK?  Or are you asking if this is even possible?

    Thanks,
    Scott

  • Hi Scott,


    thanks for the reply. What I explained in my post is what I have actually done. But it doesn't work ! This is why I asked whether it is possible at all what I am trying to do, and secondly, whether I chose the right way to do this. Maybe I have the right way, but I'm missing some detail.

    Maybe it it possible in general, but I need a totally different approach. That's why I asked the two questions.

    My approach is to use a second task created from the telnet task. Having 2 tasks, one can listen using the socket's fdSelect and recv function inside a loop, the other task can send using the socket's send function inside a loop. The socket handle is a global variable, accessible to both tasks. Sending and receiving is realized with the ConPrintf and ConGetCh functions from the example file console.c


    So far I have the impression, that I cannot set up the same socket to be listening while at the same time being sending something.

    Maybe I should open a second socket using the same telnet connection. (if this is even possible)

    Maybe the socket functions are not thread-safe beeing called from 2 different tasks on the same socket.

    I would prefer not using 2 tasks but only 1, and figure out a way of regularly checking the file descriptor's input buffer (in a non-blocking way) to know whether an Escape has been received.

    Thanks.

    Frank

  • Hi Scott,


    I was just wondering whether you had any feedback from the expert. It's really just a  problem of "full duplex" over the telnet socket, in contrary to the question & answer method used in the examples, using recv (blocking) and send function.

    I'd like to continuously send out telnet data while in the same time beeing able to catch a received character.


    Any help is very much appreciated.

    Thanks,

    Frank

  • Frank,

    Sorry for the slow reply.  The expert I want to discuss this with is out of office.

    Regarding using one task, and the blocking recv() call…

    Maybe you can modify the example to call fdStatus() [with request=FDSTATUS_RECV], to query if there is any data to be read (and if recv() should be called)?

    Have you tried specifying the MSG_DONTWAIT flag when calling recv()?

    For your two task case... I think you should be able to share the socket for your use case, but I’m not positive.  Did you maybe try using fdShare() after opening the socket?

    Hope this helps…

    Scott