Hi everyone,
during the course of a research project I have developed a PakBus API in Python. The project is called PyPak. We use it mainly to transfer data from CR 1000 data loggers to a MySQL database over TCP/IP. The software has been tested on CR 1000 data loggers running OSVersion 17 in a Unix/Linux environment. However, since it is written in Python, it should also run on other platforms.
The current version of PyPak supports several useful functions:
- get/set data logger clock
- get table definitions
- read table data
- file upload, download and control functions
- basic handling of devconfig commands
The code is licensed under the GPL and can be downloaded from here:
http://sourceforge.net/projects/pypak
Coments, tests, feedbacks and additional developers are welcome!
Kind regards
Dietrich
* Last updated by: dgf on 1/5/2010 @ 8:12 AM *
新对话如下:
These APIs support serial communication?
Thanks!
新对话如下:
> These APIs support serial communication?
Most routines in PyPak should not care if the transmission line is a socket or a serial device. However, on my CR1000 I had some trouble getting the initialization for the serial PakBus protocol to work.
As a workaround, I have used a PPP connection on the serial line between logger and PC instead of a direct serial link. Then PyPak works just like over any other TCP/IP connection.
Kind regards
Dietrich
新对话如下:
There is a possibility that the initialisation does not work because for serial comms there is a baud rate speed detection process the logger goes through by analysing the ring packets. That process may be not work too well if the timing of the characters sent from the computer is not well controlled.
IF that is the problem (which is a guess on my part) this should not be such a problem if the baud rate is fixed in the datalogger (which you can do via the logger setup). In the case of the CR200, the baud rate is fixed anyway at 9600 baud.
新对话如下:
Hi,
I'm having several problems to configure the communication between the Linux PC and the CR200 via the serial port.
Could someone link me some guide about the configuration of pakbus.conf expecially when using serial port?
I think I'm misunderstanding the meaning of host and port.
@dgf Hello, you've talked about a workaround to use the serial port, could you be more detailed about it?
Sincerly,
Simone.
新对话如下:
Hi Simone,
I had some trouble getting direct serial connections to work on my test CR1000. It might be the problem mentioned by @aps but I have not been able to investigate this any further.
The current PyPak version only understands host names or IP addresses in pakbus.conf. The workaround is to set up a PPP connection between the logger and the Linux PC. You need to run pppd on the Linux side with minimal settings: no authentication, dialing etc.. Something like
pppd /dev/ttyS0 9600 debug noauth nodetach 10.0.0.1:10.0.0.2
should suffice. In this case, the PC would have IP 10.0.0.1 and the logger 10.0.0.2. Of course, you can chose any other IP that works with your network setup.
Once pppd is running, start a PPP connection on the logger. If it is successful, you should be able to ping the logger from your PC. When that works, you should be able to put your logger'S IP into pakbus.conf and run PyPak.
If this does not solve your problem, please contact me on the email address that is provided in the PyPak REAME file.
Kind regards
Dietrich
新对话如下:
Thank you very much for your fast reply dgf.
I took some time in testing your solution, your help has been very accurate but I have not been able to make it work.
After some analysis I think that my professor has installed some kind of security system that doesn't allow me to manage the ppp connection, since while i'm testing the pppd on my computer works, but not on the remote server.
I have not been able to fully test your program on my home server, since the Datalogger is connected on the remote server that is far away from my home :)
I'm not good with Phyton language, so I'm not going to do more test, but I'll want to suggest to the graduating student who will succeed me in the project, to take a look at your API, because I think that changing the object that manage the send and receive of the data, from socket to serial (with some trick), should do the job.
Thanks again for your effort.
Sincerly,
Simone.
新对话如下:
Hi dgf & Sasori,
I haven't gotten around to using pyPak but I've had good luck using Serial to Network Proxy (ser2net) to connect directly with array based data loggers:
http://ser2net.sourceforge.net/
Depending on your operating system it could be as easy to install as:
# apt-get install ser2net
Copied from my configuration:
/etc/ser2net.conf
8000:raw:60:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT
Then accessing the logger is fairly simple, for example:
telnet 127.0.0.1 8000
--Bob