Giter Site home page Giter Site logo

reeprotocol's Introduction

reeprotocol

https://travis-ci.org/javierdelapuente/reeprotocol.svg?branch=master https://coveralls.io/repos/github/javierdelapuente/reeprotocol/badge.svg?branch=master

IEC-870-5-102 for REE Spanish Electric meters

Based on http://www.ree.es/sites/default/files/01_ACTIVIDADES/Documentos/Documentacion-Simel/protoc_RMCM10042002.pdf and http://www.ree.es/sites/default/files/01_ACTIVIDADES/Documentos/Documentacion-Simel/AMPLIACION%20DEL%20PROTOCOLO%20Fase%202%202003-02-10.pdf

Installation

Just checkout the code, install the requirements and launch the examples with real information from devices.

To use the modem interface you will need a gsm modem. Have a look at http://www.ree.es/sites/default/files/01_ACTIVIDADES/Documentos/Documentacion-Simel/Simel_gsm_v1.0.pdf for more information.

Functions Implemented

At the moment this project is Work In Progress. I am not sure of all the aspects of the protocol, so I am writing/testing the libraries against real devices. So for now do not except this project to be anything more than a spike/prototype.

However at 20180613, there are working examples to read hourly data from meters both with tcpip and with a gsm connection.

reeprotocol's People

Contributors

ecarreras avatar javierdelapuente avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reeprotocol's Issues

USB to Infrared

Hello

I want to use this code conecting a USB to Infrared conector in the meters.
Somebody could tell me how to use the examples code in this case.

Thanks

asdu_resp object has no causa_tm attribute.

Sometimes when I trying to read data from meters points, I got an exception: asdu_resp object has no causa_tm attribute.

Why this exception can be caused? You also mention that in protocol.py:

""" this function makes a very ugly assumption,
if you don't iterate over all elements, the program will fail"""

Error with TCP/IP

When i try connect with tcpip_cliente.py, script send init bytes and i finally get a error:

INFO:root:->10:49:01:00:4a:16
Traceback (most recent call last):
File ".\tcpip_cliente.py", line 76, in
run_example(ip, port, der, dir_pm, clave_pm)
File ".\tcpip_cliente.py", line 23, in run_example
link_layer.link_state_request()
File "D:...\gitproyect\reeprotocol\examples..\reeprotocol\protocol.py", line 116, in link_state_request
resp = self.get_frame()
File "D:...\gitproyect\reeprotocol\examples..\reeprotocol\protocol.py", line 107, in get_frame
bt = self.physical_layer.get_byte(timeout)
File "D:...\gitproyect\reeprotocol\examples..\reeprotocol\tcpip.py", line 44, in get_byte
return self.queue.get(True, timeout)
File "C:\Users...\AppData\Local\Programs\Python\Python36-32\lib\queue.py", line 172, in get
raise Empty
queue.Empty

With other programs, for instance ISM "Lector de contadores", when i send:

->10-49-01-00-4A-16

I receive:

<-10-0B-01-00-0C-16

.....

Moxa Physical Layer

Hello @javierdelapuente We've made reeprotocol_moxa which is a Physical Layer to Moxa devices and released as a library which depends on your library.

We have done as a separated library because it's not part of the standard and we didn't want to mess up this repository with non standard physical layers.

This is not a issue, but if you want to put it in some place, eg. Wiki you can.

Connection Serial Cable

In my case i have a Spanish Electrical meter using a serial cable (without modem), and when i executed the script:
py .\modem_cliente.py --port="COM6" --der=1 --dir_pm=1 --clave_pm=1
I can't connect. I always get:

INFO:reeprotocol:nothing yet...
INFO:reeprotocol:iterate read thread

I mean that:
der = Link adress
dir_pm = mesaurement point
clave_pm = read password
is it correct? can i use a serial cable without modem?
thanks

Error with old serial modem com

I have a old serial modem, and when i run modem_cliente.py, i get the next error:

NFO:reeprotocol:try open port 0
INFO:reeprotocol:serial port COM7 opened
INFO:reeprotocol:read thread Starting
INFO:reeprotocol:sending command ATZ
INFO:reeprotocol:iterate read thread
INFO:reeprotocol:->41:54:5a:0d
INFO:reeprotocol:<-41:54:5a:0d:0d:0a:4f:4b:0d:0a
INFO:reeprotocol:R-ATZ

INFO:reeprotocol:R-OK

INFO:reeprotocol:iterate read thread
INFO:reeprotocol:sending command AT+CBST=7,0,1
INFO:reeprotocol:iterate read thread
INFO:reeprotocol:->41:54:2b:43:42:53:54:3d:37:2c:30:2c:31:0d
INFO:reeprotocol:<-41:54:2b:43:42:53:54:3d:37:2c:30:2c:31:0d:0d:0a
INFO:reeprotocol:R-AT+CBST=7,0,1

INFO:reeprotocol:iterate read thread
INFO:reeprotocol:<-45:52:52:4f:52:0d:0a
INFO:reeprotocol:R-ERROR

After, the modem execute the dial, but when it send the command AT0, get other error:

INFO:reeprotocol:sending command ATH0
INFO:reeprotocol:->41:54:48:30:0d
INFO:reeprotocol:<-0d:0a:4e:4f:20:43:41:52:52:49:45:52:0d:0a
INFO:reeprotocol:R-ATD657872953

INFO:reeprotocol:R-NO CARRIER

INFO:reeprotocol:iterate read thread
INFO:reeprotocol:iterate read thread
Traceback (most recent call last):
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python36-32\lib\site-packages\reeprotocol\modem.py", line 30, in connect
    self.initialize_modem()
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python36-32\lib\site-packages\reeprotocol\modem.py", line 63, in initialize_modem
    self.waitforconnect()
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python36-32\lib\site-packages\reeprotocol\modem.py", line 83, in waitforconnect
    raise ConnectionError("Error Waiting for connection")
ConnectionError: Error Waiting for connection

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".\modem_cliente.py", line 75, in <module>
    run_example(port, phone_number, der, dir_pm, clave_pm)
  File ".\modem_cliente.py", line 20, in run_example
    physical_layer.connect()
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python36-32\lib\site-packages\reeprotocol\modem.py", line 33, in connect
    raise ConnectionError(e)
ConnectionError: Error Waiting for connection
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python36-32\lib\site-packages\reeprotocol\modem.py", line 132, in read_port
    response = self.sport.read(16)
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python36-32\lib\site-packages\serial\serialwin32.py", line 269, in read
    win32.ResetEvent(self._overlapped_read.hEvent)
AttributeError: 'NoneType' object has no attribute 'hEvent'

Fork this repo

Hello 🙋‍♂️ @javierdelapuente ,
we will actively work in our fork because we plan to use this library in production environment 🚀 and we can't be blocked waiting for our pull-requests to be reviewed and merged with the current time window:

  • #1 (~ 7 months until merged)
  • #8 (~ 1.5 month and still open)
  • #9 (~1 month and still open)

In our fork we have already implemented new ASDUs and Working with IP Layer and Moxa (IP + Phone):

Our steps to completly for are described in gisce#8

Implemented ASDUs

  • C_AC_NA_2: Autentificación
  • C_CI_NU_2: Leer incrementales absolutos
  • M_IT_TG_2: Respuesta Leer incrementales absolutos
  • C_CI_NT_2: Leer totales absolutos
  • M_IT_TK_2: Respuesta de C_CI_NT_2
  • C_FS_NA_2: Finalizar sesión
  • C_TI_NA_2: Leer fecha y hora actuales
  • M_TI_TA_2: Respuesta Fecha y hora actuales
  • C_RD_NA_2: Leer identificador de fabricante y equipo
  • P_MP_NA_2: Respuesta Identificador del fabricante y equipo
  • C_TA_VC_2: Leer Información de Tarificación (Valores en Curso)
  • M_TA_VC_2: Respuesta Información de Tarificación (Valores en Curso)
  • C_TA_VM_2: Leer Información de Tarificación (Valores Memorizados)
  • M_TA_VM_2: Respuesta Información de Tarificación (Valores Memorizados)
  • C_CB_UN_2 (opcional): Similar a C_CI_NU_2 y C_CI_NT_2
  • M_IB_TK_2: Respuesta de C_CB_UN_2

Rename the project

We will change the name of the project to iec870ree and you can continue using your original name, we will maintain the LICENSE and your authorship.

If you don't have time to work in your repo and will join forces we will be very happy to give you write permission to our repo.

Many thanks for your amazing project and starting point !! 🤗🍻🍰

Error Línea 199 Example

Muy buenas Javier,

estoy probando tu aplicación para comunicar mediante el protocolo iec-102, estoy utilizando visual studio code y cuando ejecuto en modo debugger el archivo ip_cliente.py de los dos ejemplos que vienen me da un error cuando ejecuta base_asdu.py en la línea 199. Refiriéndose a la variable self.buffer.extend(struct.pack("H",self.der)). El error exactamente es que está esperando un tipo integer.

Me podrías comentar sobre esto?

Muchas gracias

ASDU-type Not Available

What is the meaning of this 'causa tranmission' code(ASDU-type Not Available)? While I am testing to library with real devices, some devices is always working properly(causa_tm = 7). But some devices is always return causa_tm code 14(Asdu type not available).

How we react to handle this situation? I have researched documentation but I did not find anything useful.
If you know to this, I can collaborate this library.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.