Hi,
I have a running project with various modules. They use shell on SD2 serial line for configuration.
I want to add CANbus for application purposes, and add configuration commands too, in order to configure modules from main controller, a PC, while still keeping the shell on serial serial port.
I plan sending a string through CAN messages, with same format used for serial line. No problems on this.
The question is: when extracted from CAN, how to redirect this string "as is" to the shell parser, so command execution will be done with the same code, as it was comming from serial line ?
Should I sent it to the BaseSequentialStream ?
The second option is to copy few line of the shell thread function, to decode command and parameters, and call the corresponding function.
Some examples would be appreciated.
Regards from a hardware guy
Angelo
How to send string to shell command parser ?
Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: How to send string to shell command parser ?
Hi,
The shell can work with anything implementing the "stream" interface, you need to create an object implementing that interface. The serial driver is such an object, the serial-over-usb is another example, the memory stream object is another example.
Giovanni
The shell can work with anything implementing the "stream" interface, you need to create an object implementing that interface. The serial driver is such an object, the serial-over-usb is another example, the memory stream object is another example.
Giovanni
Re: How to send string to shell command parser ?
Hi,
I will give it a try.
And if my application require ethernet, I would add a telnet port. So the check and configuration could be done either by serial, CAN or Ethernet. Or all 3 at the same time.
The application is to drive old roadrail modeltrains. They are not digital, and it would be nice if the complete system runs unattended during expo and shows.
Angelo
I will give it a try.
And if my application require ethernet, I would add a telnet port. So the check and configuration could be done either by serial, CAN or Ethernet. Or all 3 at the same time.
The application is to drive old roadrail modeltrains. They are not digital, and it would be nice if the complete system runs unattended during expo and shows.
Angelo
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: How to send string to shell command parser ?
You can spawn multiple shells on different streams, no problems.
Giovanni
Giovanni
Re: How to send string to shell command parser ?
Hello,
I think I got it. Will check tomorrow.
I should create a buffer and a memorystream. Init the stream. Then create a new shell thread on this stream, using the existing command table. And finaly put/write chars extracted from the CANBUS protocol to the memorystream. And tadaaaaaaa, existing command code will do the job as it do on the serial port. And so on for the ethernet port.
Angelo
I think I got it. Will check tomorrow.
I should create a buffer and a memorystream. Init the stream. Then create a new shell thread on this stream, using the existing command table. And finaly put/write chars extracted from the CANBUS protocol to the memorystream. And tadaaaaaaa, existing command code will do the job as it do on the serial port. And so on for the ethernet port.
Angelo
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: How to send string to shell command parser ?
You could skip the memory stream and implement your own buffers (one per direction).
HAL queues could do that.
Giovanni
HAL queues could do that.
Giovanni
-
- Posts: 166
- Joined: Wed Jan 09, 2019 12:37 pm
- Has thanked: 19 times
- Been thanked: 31 times
Re: How to send string to shell command parser ?
For Ethernet, it's fairly easy to create a basic web server (see $CHIBIOS/ext/lwip/src/apps/httpd directory). That allows simple web pages to interface with the system, possibly with a bit of javascript if you want to dynamically update the display.
If you add a level of abstraction from the shell interface code, most of the code can be used for either interface.
Mike
If you add a level of abstraction from the shell interface code, most of the code can be used for either interface.
Mike
Re: How to send string to shell command parser ?
Hi,
I tested with memory stream. Everything compiles and execute well. But, it doesn't work. As buffer is unique for in and out, when starting, the shell sends itself the welcome message and first prompt. And loop continously trying to decode the previous error message as a new input command.
So I need to use buffer or queues. But as a "hardware oriented guy"I didn't understand anything about all this stuff.
A little big help would be appreciated.
Angelo
I tested with memory stream. Everything compiles and execute well. But, it doesn't work. As buffer is unique for in and out, when starting, the shell sends itself the welcome message and first prompt. And loop continously trying to decode the previous error message as a new input command.
So I need to use buffer or queues. But as a "hardware oriented guy"I didn't understand anything about all this stuff.
A little big help would be appreciated.
Angelo
Re: How to send string to shell command parser ?
mikeprotts wrote:For Ethernet, it's fairly easy to create a basic web server (see $CHIBIOS/ext/lwip/src/apps/httpd directory). That allows simple web pages to interface with the system, possibly with a bit of javascript if you want to dynamically update the display.
let's make things simple. At least for me
mikeprotts wrote:.... most of the code can be used for either interface.
Exactly what I want.
Angelo
-
- Posts: 166
- Joined: Wed Jan 09, 2019 12:37 pm
- Has thanked: 19 times
- Been thanked: 31 times
Re: How to send string to shell command parser ?
A simple example is in the demo code, e.g.:
ChibiOS_18.2.1/demos/STM32/RT-STM32F107-OLIMEX_P107-LWIP/web/web.c
The basic for a simple web server is to handle GET only. The server reads the URL send by the client, which might be (if board has IP address 192.168.1.32) to sound whistle once with short blast:
http://192.168.1.32/whistle?1&short
The server will see:
GET /whistle?1&short HTTP/1.1
So the server can perform the required process (maybe startWhistleMilliseconds(1000) which would probably run asynchronously on another thread) and send back a simple page with results. The web page can start simple:
<http>
<head>
<title>
Whistle result
</title>
</head>
<body>
<p>
One short blast requested
</p>
</body>
</html>
Once that's working you could add fancy stuff with javascript and images loaded from an SD card or a separate server (I use a Raspberry Pi for that).
Mike
ChibiOS_18.2.1/demos/STM32/RT-STM32F107-OLIMEX_P107-LWIP/web/web.c
The basic for a simple web server is to handle GET only. The server reads the URL send by the client, which might be (if board has IP address 192.168.1.32) to sound whistle once with short blast:
http://192.168.1.32/whistle?1&short
The server will see:
GET /whistle?1&short HTTP/1.1
So the server can perform the required process (maybe startWhistleMilliseconds(1000) which would probably run asynchronously on another thread) and send back a simple page with results. The web page can start simple:
<http>
<head>
<title>
Whistle result
</title>
</head>
<body>
<p>
One short blast requested
</p>
</body>
</html>
Once that's working you could add fancy stuff with javascript and images loaded from an SD card or a separate server (I use a Raspberry Pi for that).
Mike
Who is online
Users browsing this forum: No registered users and 26 guests