Thanks a ton. Would go through them.

Thanks,
Aditya Xavier.

> On 21-Apr-2018, at 11:45 PM, marko kiiskila <[email protected]> wrote:
> 
> Console itself uses uart driver interface. Other examples you can use
> 
> mgmt/newtmgr/transport/nmgr_uart/src/nmgr_uart.c
> https://github.com/runtimeco/mynewt_arduino_zero/blob/master/libs/espduino/src/espduino.c
> boot/boot_serial/src/boot_uart.c
> 
> the air quality sensor tutorial:
> http://mynewt.apache.org/latest/os/tutorials/air_quality_sensor/#air-quality-sensor-project
>  
> <http://mynewt.apache.org/latest/os/tutorials/air_quality_sensor/#air-quality-sensor-project>
> 
>> On Apr 21, 2018, at 9:06 PM, Aditya Xavier <[email protected]> wrote:
>> 
>> I went through HAL UART APIs however am not able to understand how to 
>> receive UART data.
>> 
>> Is there any example out there which would tell me how to use the relevant 
>> functions (hal_uart_start_rx ? ) so that we can receive binary data over 
>> UART ?
>> 
>> Any help is much appreciated.
>> 
>> Thanks,
>> Aditya Xavier.
>> 
>> 
>>> On 21-Apr-2018, at 8:44 PM, Aditya Xavier <[email protected]> wrote:
>>> 
>>> Could you specifically point how to use the uart driver interface?
>>> 
>>> I’ll look at how to base64 encode as well..
>>> 
>>> Sent from my iPhone
>>> 
>>>> On 21-Apr-2018, at 8:17 PM, marko kiiskila <[email protected]> wrote:
>>>> 
>>>> Console is for printable characters only, not meant for binary data.
>>>> You should go straight to uart driver interface, or base64 encode your 
>>>> CBOR.
>>>> 
>>>>> On Apr 21, 2018, at 4:30 PM, Aditya Xavier <[email protected]> wrote:
>>>>> 
>>>>> Hi Mynewt Team,
>>>>> 
>>>>> It seems UART is not capable of handling non-asci characters and instead 
>>>>> enters new line on occurrence of one.
>>>>> 
>>>>> Thanks,
>>>>> Aditya Xavier.
>>>>> 
>>>>> 
>>>>>> On 21-Apr-2018, at 5:28 PM, Aditya Xavier <[email protected]> wrote:
>>>>>> 
>>>>>> Hi Mynewt Team,
>>>>>> 
>>>>>> Am facing issues with console_read API.
>>>>>> 
>>>>>> I have a MCU sending CBOR data to nRF over UART.
>>>>>> 
>>>>>> Console_read works perfect when receiving data from USB->Serial adapter 
>>>>>> (Computer) & RTT.
>>>>>> 
>>>>>> Console_read give multiple hits ( i.e. multiple times it would reach 
>>>>>> either /*Got Full line - break …*/ or /*Do some work…*/
>>>>>> 
>>>>>> How do I fix such a situation.
>>>>>> 
>>>>>> Thanks,
>>>>>> Aditya Xavier.
>>>>>> 
>>>>>> 
>>>>>> #define MAX_INPUT 128
>>>>>> 
>>>>>> static void
>>>>>> read_function(void *arg)
>>>>>> {
>>>>>> char buf[MAX_INPUT];
>>>>>> int rc; 
>>>>>> int full_line;
>>>>>> int off;
>>>>>> 
>>>>>> off = 0;
>>>>>> while (1) {
>>>>>>   rc = console_read(buf + off, MAX_INPUT - off, &full_line);
>>>>>>   if (rc <= 0 && !full_line) {
>>>>>>       continue;
>>>>>>   }
>>>>>>   off += rc;
>>>>>>   if (!full_line) {
>>>>>>       if (off == MAX_INPUT) {
>>>>>>           /*
>>>>>>            * Full line, no newline yet. Reset the input buffer.
>>>>>>            */
>>>>>>           off = 0;
>>>>>>       }
>>>>>>       continue;
>>>>>>   }
>>>>>>   /* Got full line - break out of the loop and process the input data */
>>>>>>   break;
>>>>>> }
>>>>>> 
>>>>>> /* Process the input line here */
>>>>>> ....
>>>>>> 
>>>>>> return;
>>>>>> }    
>>>>>> static void myapp_process_input(struct os_event *ev);
>>>>>> 
>>>>>> static struct os_eventq avail_queue;
>>>>>> 
>>>>>> static struct console_input myapp_console_buf;
>>>>>> 
>>>>>> static struct os_event myapp_console_event = {
>>>>>> .ev_cb = myapp_process_input,
>>>>>> .ev_arg = &myapp_console_buf
>>>>>> };
>>>>>> 
>>>>>> /* Event callback to process a line of input from console. */
>>>>>> static void
>>>>>> myapp_process_input(struct os_event *ev)
>>>>>> {
>>>>>> char *line;
>>>>>> struct console_input *input;
>>>>>> 
>>>>>> input = ev->ev_arg;
>>>>>> assert (input != NULL);
>>>>>> 
>>>>>> line = input->line;
>>>>>> /* Do some work with line */
>>>>>>    ....
>>>>>> /* Done processing line. Add the event back to the avail_queue */
>>>>>> os_eventq_put(&avail_queue, ev);
>>>>>> return;
>>>>>> }
>>>>>> 
>>>>>> static void 
>>>>>> myapp_init(void)
>>>>>> {
>>>>>> os_eventq_init(&avail_queue);
>>>>>> os_eventq_put(&avail_queue, &myapp_console_event);
>>>>>> 
>>>>>> console_set_queues(&avail_queue, os_eventq_dflt_get());
>>>>>> }
>>>>>> 
>>>>> 
>>>> 
>> 
> 

Reply via email to