AT commands serial port

203 views
Skip to first unread message

mk.j...@gmail.com

unread,
Oct 27, 2015, 8:22:19 AM10/27/15
to automatak-dnp3
Hi Adam,

I'm using OpenDNP3-2.0.x to create a master to communicate with a RTU through à serial port.

Every thing is OK.

But now I'm wondring what's the best way to send AT commands to serial port in the begining and then let the master send DNP3 request ?

Thanks for your reply

Mekki

J Adam Crain

unread,
Oct 27, 2015, 11:28:30 AM10/27/15
to automatak-dnp3
Hi Mekki,

Are you configuring a modem? This is not something we have tried to address in the library. I must admit ignorance to modem init strings, etc.

A couple of options:

1) Prior to adding the serial channel in opendnp3, open the port with whatever serial API your platform uses and configure the modem.

2) If the modem requiers the port to stay open (i.e. send the commands prior to dnp3 operation but after opening), you'll have to hack the serial port class
and insert code for modem initialization.

Let me know what the requirements are, and I'll try to suggest a path.

-Adam

mk.j...@gmail.com

unread,
Oct 27, 2015, 12:38:02 PM10/27/15
to automatak-dnp3
Hi Adam,

For modem configuration, using a basic serial port terminal is enough.
That's the way I do configuration.
Once configuration is finished
AT&W sent from the serial port terminal saves my setting into modem.


The problem I noticed is that when the master is runing, the serial port is busy since it must stay open by the master.

I've also seen that the serial port is managed thanks to ASIO library.

The main idea is to do something like this :

1 - // Connect via  Serial port to a outstation       
    auto pChannel = manager.AddSerial("serialclient", FILTERS, TimeDuration::Seconds(5), TimeDuration::Seconds(5),SerialSettings);
   
2 - Send the following command through ASIO to make a data call  :
    Exemple
    ATD0617120387
    This string command will dial a phone number and when the call succed, we get a return string "CONNECT 9600"
   
   

3// Create a new master on a previously declared port, with a
    // name, log level, command acceptor, and config info. This
    // returns a thread-safe interface used for sending commands.
    auto pMaster = pChannel->AddMaster(
                       "master",                                        // id for logging
                       PrintingSOEHandler::Instance(),                    // callback for data processing               
                       asiodnp3::DefaultMasterApplication::Instance(),    // master application instance
                       stackConfig                                        // stack configuration
                   );   

...

Mekki

J Adam Crain

unread,
Oct 27, 2015, 1:50:17 PM10/27/15
to automatak-dnp3
Ok, I see.

I believe that you'll then need to make modifications to the serial port class itself. Namely, you'll need to inject this behavior after a successful open, but before
the physical layer calls back to the upper layer to say its ready for writing:

https://github.com/automatak/dnp3/blob/2.0.x/cpp/libs/src/asiopal/PhysicalLayerSerial.cpp#L75

You'll need to use async read/write methods so that you don't block the thread, e.g:

https://github.com/automatak/dnp3/blob/2.0.x/cpp/libs/src/asiopal/PhysicalLayerSerial.cpp#L109
https://github.com/automatak/dnp3/blob/2.0.x/cpp/libs/src/asiopal/PhysicalLayerSerial.cpp#L119

You'll probably also want to set some kind of timer that you get the "CONNECT 9600" data back within a reasonable delay.

I would start by just reviewing how the current serial port class works w/ ASIO, and then design a way to extend it.

Ultimately, it would be nice if we could abstract this process somehow so that people could optionally inject some interface when creating
the serial port class that would allow them to do custom modem initializations.

-Adam

mk.j...@gmail.com

unread,
Oct 28, 2015, 6:01:53 AM10/28/15
to automatak-dnp3
Hi Adam,

Thank you a lot for your quick reply, I'll have a look at the serial class to see what I can do.

It will be realy a good thing if we could have that kind of behavior in openDNP3.

And it will be more perfect if OpenDNP3 architecture allows this :

In the master side

  1. Open Serial Port
  2. Establishing a permanent Data Call, by sendind AT commands to modem via serial port
  3. Creating the master

In the Outstation side
Genaral Case :
  1. Open Serial Port
  2. Establishing a permanent Data Call, by sendind AT commands to modem via serial port
  3. Creating the master

Report By Exception case :

When there are somme events to report

  1. We supose serial port is already open in the outstation, and the outstation is already created
  2. Establish a data call by sendind ATD command to modem via serial port
  3. Sending DNP3 report
  4. Hang up the data call

Mekki

mk.j...@gmail.com

unread,
Nov 9, 2015, 6:03:01 AM11/9/15
to automatak-dnp3
Hi Adam

I placed a ASIO write command inside DoOpenSuccess() to make the modem dialing for a data call.
Now The master establish first a data Call, and continue it's job naturaly

I'm tring to do the same thing in the outstation side :
If there is some Unsolicited msg to send
then establish a data call and send the unsolicited msgs

I fell that I it's possible to do It with some changes in CheckForUnsolicited()


Thank you for your Help.

Mekki
Reply all
Reply to author
Forward
0 new messages