NetBurner Community Forum

A community of NetBurner users gathering to discuss NetBurner hardware, software, design and projects
It is currently Thu Dec 14, 2017 9:49 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Tue Dec 08, 2015 3:28 pm 

Joined: Tue Nov 24, 2015 3:54 pm
Posts: 1
I am new to the Netburner platform and am in need of some guidance on how to setup a timer to detect gaps in received characters in order to determine the end of a response to a MODBUS-RTU query. Basically, a response message is defined as a gap larger the 3.5 character times between successive bytes in a message stream. In my code I want to be able to detect the gaps. I have successfully used a decremented counter that is reset to a known timing value on each character received. When the count reaches zero the message frame receipt is completed.

I prefer ISR code for the serial RX processing but would need to add the code to update the countdown mechanism/ restart a one-shot timer.

My platform is the SBL2E with the 2.7.3 IDE.

Thanks in advance for any guidance.


Top
 Profile  
 
PostPosted: Tue Dec 08, 2015 6:52 pm 

Joined: Thu Apr 24, 2008 3:58 pm
Posts: 712
Add a function:

void MyRecievedData(BYTE data)
{//This function will be called in the ISR for eaqch recieved serial BYTE...
//Do what you will, check your timers etc....
}

//Point the serial port data handler at your function..
//port is 0,1,2
SerialPortCallBack[port]=MyRecievedData;


//Just open the serial port in the normal way.
InitIRQUart(port,baud,1,8,eParityNone);

//Now every received byte will go to your special function rather than to the system processing...
//It will happen as soon as the ISR is serviced... which unless you have a lot of something else going on will be
//within a usec of so of char receive...


Top
 Profile  
 
PostPosted: Fri Apr 29, 2016 5:48 pm 

Joined: Mon Apr 28, 2008 7:32 am
Posts: 75
Does this apply only to SB2LE? I can't find any mention of SerialCallBack in any docs or source other than an SB2LE example.

Joe


Top
 Profile  
 
PostPosted: Sun May 01, 2016 12:06 pm 

Joined: Thu Apr 24, 2008 3:58 pm
Posts: 712
Yes that specific call is SBL2E specific...

For the non l2e you have two approaches...

1)
Under the web site support there is a docs and downloads link...
look under your platform
Then look under development kit...
There is a how to write your own serial driver set of examples...


2)There is a function pointer in the serial drivers that will
get called by the ISR for every received charator...
Its documented in serinternal.h

so

if you have a function..

void MyProcessRxChar(int num, BYTE c);

You can

#include <serinternal.h>


UartData[port_number].m_pPutCharFunc=MyProcessRxChar;

The num parameter is the serial port number the call back us being called for...


Top
 Profile  
 
PostPosted: Sun May 01, 2016 6:07 pm 

Joined: Mon Apr 28, 2008 7:32 am
Posts: 75
Hi Paul,

Thanks. I see in Serial.cpp for 5234 that those pointers are assigned BasePutChar and BaseGetChar on initialization, so changing them to point to your own functions would bypass the standard FIFOs without fiddling with the ISRs. That seems a lot simpler than completely replacing the ISRs as in the bare driver example.

Joe


Top
 Profile  
 
PostPosted: Sun May 01, 2016 10:04 pm 

Joined: Thu Apr 24, 2008 3:58 pm
Posts: 712
If your going to modify the TX pointer then you will have to return -1 when you have no chars to send.
Anytime you have returned -1 you must call

void WakeTx( int x )

When you want the transmitter to wake up again....

See serwrite in serial.cpp


Paul


Top
 Profile  
 
PostPosted: Mon May 02, 2016 9:57 am 

Joined: Mon Apr 28, 2008 7:32 am
Posts: 75
Thanks, I will give it a try and report back.

Does all of this apply to MOD5441X and its 10 UARTs? I have an application to build a simulation that runs on that board.

Joe


Top
 Profile  
 
PostPosted: Mon May 02, 2016 10:01 am 

Joined: Thu Apr 24, 2008 3:58 pm
Posts: 712
Yes it applies to all standard netburner devices (IE everything except SBL2's and MOD5213)


Top
 Profile  
 
PostPosted: Wed Jun 14, 2017 3:20 am 
User avatar

Joined: Mon Mar 27, 2017 3:30 am
Posts: 4
Location: India
It applies to every standard model. Thank you for sharing information.

_________________
Mobile application development company India | Mobile application development company Bangalore


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 8 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group