[Armadeus-commitlog] armadeus branch, master, updated. release-3.4-221-ge2223d6
Brought to you by:
sszy
|
From: Fabien M <fa...@us...> - 2011-06-23 09:01:29
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via e2223d6de323d3a1a278b040c54cebb490c083ea (commit)
via 157724ee30cb26ac3616ddafbffae2bffd183545 (commit)
from a52f4784714ed961b9697c538e36387f96b46029 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e2223d6de323d3a1a278b040c54cebb490c083ea
Author: Fabien Marteau <fab...@ar...>
Date: Thu Jun 23 11:00:17 2011 +0200
[buidroot][package][as_devices] Change as_gpio_open() argument, use gpio number instead of port letter plus pin number
commit 157724ee30cb26ac3616ddafbffae2bffd183545
Author: Kevin JOLY <jol...@gm...>
Date: Thu Jun 23 09:50:58 2011 +0200
[buildroot][package][anybusd] Add anybusd in armadeus package
Signed-off-by: Kevin JOLY <jol...@gm...>
-----------------------------------------------------------------------
Summary of changes:
buildroot/package/armadeus/Config.in | 1 +
buildroot/package/armadeus/anybusd/Config.in | 4 +
buildroot/package/armadeus/anybusd/anybusd.mk | 21 ++
.../package/armadeus/as_devices/as_devices.mk | 2 +-
.../mcp25020_ctrl => packages/anybusd}/Makefile | 23 +--
target/packages/anybusd/S60anybusd | 41 ++++
target/packages/anybusd/anybusd.c | 201 ++++++++++++++++++++
target/packages/as_devices/Makefile | 2 +-
target/packages/as_devices/c/as_gpio.c | 32 +---
target/packages/as_devices/c/as_gpio.h | 14 +--
target/packages/as_devices/c/as_gpio_2_6_29.c | 17 +-
target/packages/as_devices/cpp/as_gpio.cpp | 25 +--
target/packages/as_devices/cpp/as_gpio.hpp | 4 +-
.../packages/as_devices/python/AsDevices/AsGpio.py | 16 +--
target/packages/as_devices/python/Makefile | 1 -
.../packages/as_devices/python/src/AsGpio_wrap.c | 51 +-----
target/packages/as_devices/test_c.h | 39 +---
17 files changed, 317 insertions(+), 177 deletions(-)
create mode 100644 buildroot/package/armadeus/anybusd/Config.in
create mode 100644 buildroot/package/armadeus/anybusd/anybusd.mk
copy target/{demos/mcp25020_ctrl => packages/anybusd}/Makefile (51%)
create mode 100755 target/packages/anybusd/S60anybusd
create mode 100644 target/packages/anybusd/anybusd.c
diff --git a/buildroot/package/armadeus/Config.in b/buildroot/package/armadeus/Config.in
index b09e93e..8a450e2 100644
--- a/buildroot/package/armadeus/Config.in
+++ b/buildroot/package/armadeus/Config.in
@@ -1,6 +1,7 @@
menu "Armadeus specific tools/utilities"
source package/armadeus/ad9889ctrl/Config.in
+source package/armadeus/anybusd/Config.in
source package/armadeus/as_devices/Config.in
source package/armadeus/ch7024ctrl/Config.in
source package/armadeus/demos/Config.in
diff --git a/buildroot/package/armadeus/anybusd/Config.in b/buildroot/package/armadeus/anybusd/Config.in
new file mode 100644
index 0000000..e822ab1
--- /dev/null
+++ b/buildroot/package/armadeus/anybusd/Config.in
@@ -0,0 +1,4 @@
+config BR2_PACKAGE_ANYBUSD
+ bool "anybusd"
+ help
+ Socket daemon for anybus module
diff --git a/buildroot/package/armadeus/anybusd/anybusd.mk b/buildroot/package/armadeus/anybusd/anybusd.mk
new file mode 100644
index 0000000..f5fbe28
--- /dev/null
+++ b/buildroot/package/armadeus/anybusd/anybusd.mk
@@ -0,0 +1,21 @@
+#############################################################
+#
+# anybusd
+#
+#############################################################
+ANYBUSD_VERSION = 0.1
+ANYBUSD_BIN_NAME = anybusd
+ANYBUSD_INIT_SCRIPT_NAME = S60anybusd
+ANYBUSD_SITE=$(TOPDIR)/../target/packages/anybusd/
+ANYBUSD_SITE_METHOD=copy
+
+define ANYBUSD_BUILD_CMDS
+ $(MAKE) CC="$(TARGET_CC)" -C $(@D) all
+endef
+
+define ANYBUSD_INSTALL_TARGET_CMDS
+ $(INSTALL) -m 0755 $(ANYBUSD_DIR)/$(ANYBUSD_BIN_NAME) $(TARGET_DIR)/usr/bin/$(ANYBUSD_BIN_NAME)
+ $(INSTALL) -m 0755 $(ANYBUSD_DIR)/$(ANYBUSD_INIT_SCRIPT_NAME) $(TARGET_DIR)/etc/init.d/$(ANYBUSD_INIT_SCRIPT_NAME)
+endef
+
+$(eval $(call GENTARGETS,package,anybusd))
diff --git a/buildroot/package/armadeus/as_devices/as_devices.mk b/buildroot/package/armadeus/as_devices/as_devices.mk
index f609288..c1d6faa 100644
--- a/buildroot/package/armadeus/as_devices/as_devices.mk
+++ b/buildroot/package/armadeus/as_devices/as_devices.mk
@@ -105,7 +105,7 @@ $(TARGET_DIR)/$(AS_DEVICES_PYTHON_TARGET_BINARY): python $(AS_DEVICES_DIR)/pytho
$(STRIPCMD) $(STRIP_STRIP_UNNEEDED) $(TARGET_DIR)/$(AS_DEVICES_PYTHON_TARGET_BINARY)/wrappers/*.so
$(AS_DEVICES_DIR)/python/AsDevices/wrappers/$(AS_DEVICES_PYTHON_BINARY): python $(AS_DEVICES_DIR)/python/Makefile
- $(TARGET_CONFIGURE_OPTS) $(MAKE) CC="$(TARGET_CC)" CXX="$(TARGET_CXX)" -C $(AS_DEVICES_DIR)/python
+ $(TARGET_CONFIGURE_OPTS) $(MAKE) CC="$(TARGET_CC)" CXX="$(TARGET_CXX)" -C $(AS_DEVICES_DIR)/python STAGING_DIR=$(STAGING_DIR)
endif
diff --git a/target/demos/mcp25020_ctrl/Makefile b/target/packages/anybusd/Makefile
similarity index 51%
copy from target/demos/mcp25020_ctrl/Makefile
copy to target/packages/anybusd/Makefile
index 10882e3..1b7e984 100644
--- a/target/demos/mcp25020_ctrl/Makefile
+++ b/target/packages/anybusd/Makefile
@@ -3,38 +3,29 @@ ARMADEUS_BASE_DIR=../../..
-include $(ARMADEUS_BASE_DIR)/Makefile.in
STAGING_DIR:=$(ARMADEUS_BUILD_DIR)/staging_dir/
-INSTALL_DIR:=$(ARMADEUS_ROOTFS_DIR)/usr/local/bin
-INIT_DIR:=$(ARMADEUS_ROOTFS_DIR)/etc/init.d
+INSTALL_DIR:=$(ARMADEUS_ROOTFS_DIR)/usr/bin/
+INITD_DIR:=$(ARMADEUS_ROOTFS_DIR)/etc/init.d/
CC:=$(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-gcc
STRIP:=$(ARMADEUS_TOOLCHAIN_PATH)arm-linux-sstrip
DEFINES=TARGET
CFLAGS= -Wall
-EXEC=mcp25020_ctrl
+EXEC=anybusd
+INIT_SCRIPT=S60anybusd
default: $(EXEC)
all: $(EXEC)
-mcp25020_ctrl.o: mcp25020_ctrl.c
+anybusd.o: anybusd.c
$(CC) $(CFLAGS) -c -o $@ $^
-$(EXEC): mcp25020_ctrl.o
+$(EXEC): anybusd.o
$(CC) $(LDFLAGS) -o $@ $^
-install: $(EXEC)
- mkdir -p $(INSTALL_DIR)
- cp $^ $(INSTALL_DIR)
- cp init_can.sh $(INIT_DIR)/S50init_can.sh
- $(STRIP) $(INSTALL_DIR)/$^
-
-uninstall:
- rm -f $(INSTALL_DIR)/$(EXEC)
- rm -f $(INIT_DIR)/S50init_can.sh
-
clean:
- rm -rf mcp25020_ctrl
+ rm -rf anybusd
rm -rf *.o
.PHONY: clean install uninstall
diff --git a/target/packages/anybusd/S60anybusd b/target/packages/anybusd/S60anybusd
new file mode 100755
index 0000000..9a169fd
--- /dev/null
+++ b/target/packages/anybusd/S60anybusd
@@ -0,0 +1,41 @@
+#! /bin/sh
+
+start() {
+ modprobe anybus_interface_platform
+ modprobe anybus_interface
+ echo -n "Starting Anybusd: "
+ anybusd
+ echo "done"
+}
+
+stop() {
+ rmmod anybus_interface
+ rmmod anybus_interface_platform
+ echo -n "Stopping Anybusd: "
+ killall anybusd
+ echo "done"
+}
+
+restart() {
+ stop
+ start
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart|reload)
+ restart
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|reload|restart}"
+ exit 1
+esac
+
+exit $?
+
diff --git a/target/packages/anybusd/anybusd.c b/target/packages/anybusd/anybusd.c
new file mode 100644
index 0000000..6ec51cb
--- /dev/null
+++ b/target/packages/anybusd/anybusd.c
@@ -0,0 +1,201 @@
+/*
+ * Daemon for interface with HMS Anybus module through FPGA.
+ * (Driver anybus_interface is required)
+ *
+ * Copyright (C) 2011 <jol...@gm...>
+ * Armadeus Systems
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <signal.h>
+#include <arpa/inet.h>
+#include <errno.h>
+
+#define DAEMON_NAME "anybusd"
+#define PID_FILE "/var/run/anybusd.pid"
+
+/* ctrl_register on Wishbone bus */
+#define ANYBUS_TRANSMIT 0x0002
+#define ANYBUS_RECEIVE 0x0004
+#define ANYBUS_4_CLOCK_CYCLES 0x0020
+#define ANYBUS_TRANSMISSION_ERROR 0x0001
+
+/* FPGA registers*/
+#define CTRL_REG 0x0002
+#define ADDRESS_REG 0x0004
+#define DATA_REG 0x0006
+
+#define ACTION 0x10
+
+/* Indication register on AnyBus module */
+#define ANYBUS_SEND 0x80
+#define ANYBUS_ACK 0x40
+
+#define PORT 4037
+
+void signal_handler(int sig)
+{
+ switch(sig) {
+ case SIGTERM:
+ exit(0);
+ break;
+ default:
+ break;
+ }
+}
+
+void write_fpga(unsigned short address, unsigned short value, void* fpga_mem)
+{
+ *(unsigned short*)(fpga_mem+(address)) = value;
+}
+
+unsigned short read_fpga(unsigned short address, void* fpga_mem)
+{
+ return *(unsigned short*)(fpga_mem+(address));
+}
+
+int write_anybus(unsigned short address, unsigned short value, void* fpga_mem)
+{
+ int n;
+ write_fpga(ADDRESS_REG, address, fpga_mem);
+ write_fpga(DATA_REG, value, fpga_mem);
+ write_fpga(CTRL_REG, ANYBUS_4_CLOCK_CYCLES | ANYBUS_TRANSMIT, fpga_mem);
+
+ if ((n = read_fpga(CTRL_REG, fpga_mem)) & ANYBUS_TRANSMISSION_ERROR) {
+ return -1;
+ }
+ return 0;
+}
+
+int read_anybus(unsigned short address, void* fpga_mem)
+{
+ int n;
+ write_fpga(ADDRESS_REG, address, fpga_mem);
+ write_fpga(CTRL_REG, ANYBUS_4_CLOCK_CYCLES | ANYBUS_RECEIVE, fpga_mem);
+
+ if ((n = read_fpga(CTRL_REG, fpga_mem)) & ANYBUS_TRANSMISSION_ERROR) {
+ return -1;
+ }
+ return read_fpga(DATA_REG, fpga_mem);
+}
+
+int main(int argc, char *argv[])
+{
+ int file_mem;
+ socklen_t sinsize;
+ int listening_socket, socket_client;
+ struct sockaddr_in sin, csin;
+ void* fpga_mem;
+ pid_t pid, sid;
+ char buffer[5];
+ int n, ret;
+ int value;
+
+ signal(SIGTERM, signal_handler);
+
+ pid = fork();
+
+ if (pid < 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ if (pid > 0) {
+ exit(EXIT_SUCCESS);
+ }
+
+ sid = setsid();
+ if (sid < 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ file_mem = open("/dev/anybus_interface", O_RDWR|O_SYNC);
+ if (file_mem < 0) {
+ printf("Can't open /dev/anybus_interface\n");
+ return -1;
+ }
+
+ fpga_mem = mmap(0, 4, PROT_READ|PROT_WRITE, MAP_SHARED, file_mem, 0);
+ if (fpga_mem == MAP_FAILED) {
+ printf("mmap failed\n");
+ close(file_mem);
+ return -1;
+ }
+
+ listening_socket = socket(AF_INET, SOCK_STREAM, 0);
+ if(listening_socket == -1) {
+ perror("socket()");
+ exit(errno);
+ }
+
+ sin.sin_addr.s_addr = htonl(INADDR_ANY);
+ sin.sin_family = AF_INET;
+
+ sin.sin_port = htons(PORT);
+
+ if(bind (listening_socket, (struct sockaddr *) &sin, sizeof sin) == -1) {
+ perror("bind()");
+ exit(errno);
+ }
+
+ if(listen(listening_socket, 1) == -1) {
+ perror("listen()");
+ exit(errno);
+ }
+ sinsize = sizeof csin;
+
+ while(1) {
+ socket_client = accept(listening_socket, (struct sockaddr *)&csin, &sinsize);
+
+ if(socket_client == -1) {
+ perror("accept()");
+ exit(errno);
+ }
+
+ ret = 0;
+
+ while(((n = recv(socket_client,buffer, sizeof buffer, MSG_WAITALL)) > 0) && (ret >= 0)) {
+
+ if(n == 5) {
+ if (buffer[0] == 's') {
+ while(write_anybus((buffer[1] << 8) + buffer[2], (buffer[3] << 4) + buffer[4], fpga_mem) < 0);
+ }
+ else if (buffer[0] == 'r') {
+ value = -1;
+ while((value = read_anybus((buffer[1] << 8) + buffer[2], fpga_mem)) < 0);
+ buffer[3] = value >> 8;
+ buffer[4] = value & 0x00FF;
+ ret = send(socket_client, buffer, sizeof buffer, 0);
+ }
+ }
+ }
+
+ close(socket_client);
+ }
+ close(file_mem);
+ close(listening_socket);
+
+ return 0;
+}
diff --git a/target/packages/as_devices/Makefile b/target/packages/as_devices/Makefile
index 94fd1a2..f2de2ec 100644
--- a/target/packages/as_devices/Makefile
+++ b/target/packages/as_devices/Makefile
@@ -40,7 +40,7 @@ $(C_LIB):
make -C c/
$(P_WRAPPER):
- make -C python/
+ make -C python/ STAGING_DIR=$(STAGING_DIR)
touch $(P_WRAPPER)
install:
diff --git a/target/packages/as_devices/c/as_gpio.c b/target/packages/as_devices/c/as_gpio.c
index eb3333b..826d128 100644
--- a/target/packages/as_devices/c/as_gpio.c
+++ b/target/packages/as_devices/c/as_gpio.c
@@ -39,32 +39,21 @@
/*------------------------------------------------------------------------------*/
-struct as_gpio_device *as_gpio_open(char aPortChar, int aPinNum)
+struct as_gpio_device *as_gpio_open(int aGpioNum)
{
struct as_gpio_device *dev;
int pin_file;
int export_file;
int retval;
- int port_num;
char buf[BUFF_SIZE];
- if (((aPortChar - 'A') > 5) || ((aPortChar - 'A') < 0) ) {
- ERROR("Wrong port name %c\n", aPortChar);
- return NULL;
- }
- if ((aPinNum < 0) || (aPinNum >= PORT_SIZE)) {
- ERROR("Wrong port num %d\n", aPinNum);
- return NULL;
- }
- port_num = (aPortChar-'A')*PORT_SIZE + aPinNum;
-
export_file = open("/sys/class/gpio/export", O_WRONLY);
if (export_file < 0) {
ERROR("Can't open /sys/class/gpio/export\nBe sure that gpiolib is under your kernel\n");
return NULL;
}
- retval = as_write_buffer(export_file, port_num);
+ retval = as_write_buffer(export_file, aGpioNum);
if (retval < 0) {
ERROR("/sys/class/gpio/export can't be written\n");
close(export_file);
@@ -74,10 +63,10 @@ struct as_gpio_device *as_gpio_open(char aPortChar, int aPinNum)
sleep(1); //XXX
- snprintf(buf, BUFF_SIZE, "/sys/class/gpio/gpio%d/value", port_num);
+ snprintf(buf, BUFF_SIZE, "/sys/class/gpio/gpio%d/value", aGpioNum);
pin_file = open(buf, O_RDWR);
if (pin_file < 0) {
- ERROR("Can't export gpio number %d (port %c pin %d)\n", port_num, aPortChar, aPinNum);
+ ERROR("Can't export gpio number %d\n", aGpioNum);
return NULL;
}
close(pin_file);
@@ -88,9 +77,7 @@ struct as_gpio_device *as_gpio_open(char aPortChar, int aPinNum)
return NULL;
}
- dev->port_num = port_num;
- dev->port_letter = aPortChar;
- dev->pin_number = aPinNum;
+ dev->port_num = aGpioNum;
return dev;
}
@@ -286,14 +273,7 @@ int32_t as_gpio_set_irq_mode(struct as_gpio_device *gpio_dev, char *mode)
int32_t as_gpio_get_pin_num(struct as_gpio_device *aDev)
{
- return aDev->pin_number;
-}
-
-/*------------------------------------------------------------------------------*/
-
-char as_gpio_get_port_letter(struct as_gpio_device *aDev)
-{
- return aDev->port_letter;
+ return aDev->port_num;
}
/*------------------------------------------------------------------------------*/
diff --git a/target/packages/as_devices/c/as_gpio.h b/target/packages/as_devices/c/as_gpio.h
index b2b241f..1352f6f 100644
--- a/target/packages/as_devices/c/as_gpio.h
+++ b/target/packages/as_devices/c/as_gpio.h
@@ -40,7 +40,6 @@ extern "C" {
*/
struct as_gpio_device {
int port_num;
- char port_letter;
int pin_number;
int fpin; /* pin file for 2.6.29 interface*/
int irq_mode;
@@ -48,12 +47,11 @@ struct as_gpio_device {
/** @brief Initialize port access
*
- * @param aPortChar character port in UPPER case
- * @param aPinNum int pin number
+ * @param aGpioNum int pin number
*
* @return error if negative value
*/
-struct as_gpio_device *as_gpio_open(char aPortChar, int aPinNum);
+struct as_gpio_device *as_gpio_open(int aGpioNum);
/** @brief Set pin direction
*
@@ -125,14 +123,6 @@ const char* as_gpio_get_irq_mode(struct as_gpio_device *gpio_dev);
*/
int32_t as_gpio_get_pin_num(struct as_gpio_device *aDev);
-/** @brief Get port letter
- *
- * @param aDev as_gpio_device pointer structure
- *
- * @return port letter, error if negative
- */
-char as_gpio_get_port_letter(struct as_gpio_device *aDev);
-
/** @brief Close port access
*
* @param aDev as_gpio_device pointer structure
diff --git a/target/packages/as_devices/c/as_gpio_2_6_29.c b/target/packages/as_devices/c/as_gpio_2_6_29.c
index a4c65c7..3c1702a 100644
--- a/target/packages/as_devices/c/as_gpio_2_6_29.c
+++ b/target/packages/as_devices/c/as_gpio_2_6_29.c
@@ -57,14 +57,20 @@
/*------------------------------------------------------------------------------*/
-struct as_gpio_device *as_gpio_open(char aPortChar, int aPinNum)
+struct as_gpio_device *as_gpio_open(int aGpioNum)
{
+ char aPortChar;
+ int aPinNum;
+
struct as_gpio_device *dev;
char gpio_file_path[50];
int ret = 0;
int file;
int value;
+ aPortChar = (aGpioNum/32) + 'A';
+ aPinNum = aGpioNum - (aPortChar-'A');
+
/* make gpio port string path */
ret = snprintf(gpio_file_path,50, "%s%c%d",
GPIO_BASE_PIN, aPortChar, aPinNum);
@@ -271,14 +277,7 @@ int32_t as_gpio_set_irq_mode(struct as_gpio_device *aDev, int aMode)
int32_t as_gpio_get_pin_num(struct as_gpio_device *aDev)
{
- return aDev->pin_number;
-}
-
-/*------------------------------------------------------------------------------*/
-
-int32_t as_gpio_get_port_letter(struct as_gpio_device *aDev)
-{
- return aDev->port_letter;
+ return aDev->pin_number + ((aDev->port_letter-'A')*32);
}
/*------------------------------------------------------------------------------*/
diff --git a/target/packages/as_devices/cpp/as_gpio.cpp b/target/packages/as_devices/cpp/as_gpio.cpp
index e3b5580..a4a7034 100644
--- a/target/packages/as_devices/cpp/as_gpio.cpp
+++ b/target/packages/as_devices/cpp/as_gpio.cpp
@@ -25,12 +25,12 @@
/** @brief Constructor: Initialize port access
*
- * @param aPortChar character port in UPPER case
- * @param aPinNum int pin number
+ * @param aGpioNum gpio number
+ *
*/
-AsGpio::AsGpio(char aPortChar, int aPinNum)
+AsGpio::AsGpio(int aGpioNum)
{
- mDev = as_gpio_open(aPortChar, aPinNum);
+ mDev = as_gpio_open(aGpioNum);
}
AsGpio::~AsGpio()
@@ -195,20 +195,3 @@ long AsGpio::getPinNum() const
}
}
-/** @brief Get port letter
- *
- * @return port letter
- */
-char AsGpio::getPortLetter() const
-{
- if (mDev != NULL)
- {
- return as_gpio_get_port_letter(mDev);
- }
- else
- {
- std::cerr<<"AsGpio device structure not allocated"<<std::endl;
- return '?';
- }
-}
-
diff --git a/target/packages/as_devices/cpp/as_gpio.hpp b/target/packages/as_devices/cpp/as_gpio.hpp
index cdd2966..d92f701 100644
--- a/target/packages/as_devices/cpp/as_gpio.hpp
+++ b/target/packages/as_devices/cpp/as_gpio.hpp
@@ -28,7 +28,7 @@
class AsGpio
{
public:
- AsGpio(char aPortChar, int aPinNum);
+ AsGpio(int aGpioNum);
virtual ~AsGpio();
long setPinDirection(char* aDirection);
@@ -43,8 +43,6 @@ public:
long getPinNum() const;
- char getPortLetter() const;
-
protected:
mutable struct as_gpio_device *mDev;
};
diff --git a/target/packages/as_devices/python/AsDevices/AsGpio.py b/target/packages/as_devices/python/AsDevices/AsGpio.py
index 2ea71c1..9cce37b 100644
--- a/target/packages/as_devices/python/AsDevices/AsGpio.py
+++ b/target/packages/as_devices/python/AsDevices/AsGpio.py
@@ -40,12 +40,11 @@ class AsGpioError(Exception):
class AsGpio:
""" Drive GPIO
"""
- def __init__(self, aPortLetter, aPinNum):
+ def __init__(self, aGpioNum):
try:
- self.__device = wrapper.gpio_open(aPortLetter, aPinNum)
+ self.__device = wrapper.gpio_open(aPinNum)
except Exception, e:
- raise AsGpioError("Can't open GPIO port "+str(aPortLetter)+\
- " pin "+str(aPinNum)+": "+str(e))
+ raise AsGpioError("Can't open GPIO number "+str(aGpioNum))
def __del__(self):
try:
@@ -131,12 +130,3 @@ class AsGpio:
except Exception, e:
raise AsGpioError(str(e))
- def getPortLetter(self):
- """ Get pin letter
- \param return pin letter
- """
- try:
- return wrapper.getPortLetter(self.__device)
- except Exception, e:
- raise AsGpioError(str(e))
-
diff --git a/target/packages/as_devices/python/Makefile b/target/packages/as_devices/python/Makefile
index a3c22b5..cb2af95 100644
--- a/target/packages/as_devices/python/Makefile
+++ b/target/packages/as_devices/python/Makefile
@@ -23,7 +23,6 @@ WRAPPER_DIR=src
PYTHON_VERS=2.4
PYTHON_SUBVERS=5
-STAGING_DIR=$(ARMADEUS_STAGING_DIR)
PYINC=$(STAGING_DIR)/usr/include/python2.4/
PYLIB=$(ARMADEUS_TARGET_DIR)/usr/lib/python$(PYTHON_VERS)
diff --git a/target/packages/as_devices/python/src/AsGpio_wrap.c b/target/packages/as_devices/python/src/AsGpio_wrap.c
index 9f6472a..7b594a8 100644
--- a/target/packages/as_devices/python/src/AsGpio_wrap.c
+++ b/target/packages/as_devices/python/src/AsGpio_wrap.c
@@ -32,7 +32,6 @@ static PyMethodDef AsGpio_wrap_methods[] = {
{"blockingGetPinValue", blockingGetPinValue, METH_VARARGS, "Blocking read pin value"},
{"getIrqMode", getIrqMode, METH_VARARGS, "Get IRQ Mode"},
{"setIrqMode", setIrqMode, METH_VARARGS, "Set IRQ Mode"},
- {"getPortLetter", getPortLetter, METH_VARARGS, "Get port letter"},
{"getPinNumber", getPinNumber, METH_VARARGS, "Get pin number"},
{"gpio_close", gpio_close, METH_VARARGS, "Close gpio"},
{NULL, NULL, 0, NULL} /* Sentinel */
@@ -45,33 +44,31 @@ void initAsGpio_wrap() /* called on first import */
}
/** @brief Initialize pin port access
- * @param aPortChar character port in UPPER case
- * @param aPinNum pin number on port
+ * @param aGpioNum pin number on port
* @return PyObject
*/
static PyObject * gpio_open(PyObject *self, PyObject *args)
{
/* parameters */
- char aPortChar;
- int aPinNum;
+ int aGpioNum;
struct as_gpio_device *dev;
PyObject *ret;
char buff[300];
/* Get arguments */
- if (!PyArg_ParseTuple(args, "ci", &aPortChar, &aPinNum))
+ if (!PyArg_ParseTuple(args, "i", &aGpioNum))
{
PyErr_SetString(PyExc_IOError,
"Wrong parameters.");
return NULL;
}
- dev = as_gpio_open(aPortChar, aPinNum);
+ dev = as_gpio_open(aGpioNum);
if (dev == NULL)
{
snprintf(buff, 300,
- "Initialization error P%c%d. Is kernel module loaded ?",
- aPortChar, aPinNum);
+ "Initialization error %d. Is kernel module loaded ?",
+ aGpioNum);
PyErr_SetString(PyExc_IOError,buff);
return NULL;
}
@@ -351,42 +348,6 @@ static PyObject * getPinNumber(PyObject *self, PyObject *args)
return Py_BuildValue("i", ret);
}
-/** @brief Get port letter
- *
- * @param aDev as_gpio_device pointer structure
- *
- * @return port letter, error if negative
- */
-static PyObject * getPortLetter(PyObject *self, PyObject *args)
-{
- /* parameters */
- struct as_gpio_device *aFdev;
-
- char buf[2];
- int ret;
-
- /* Get arguments */
- if (!PyArg_ParseTuple(args, "l", (long *)&aFdev))
- {
- PyErr_SetString(PyExc_IOError,
- "Wrong parameters.");
- return NULL;
- }
-
- ret = as_gpio_get_port_letter(aFdev);
- if (ret < 0)
- {
- PyErr_SetString(PyExc_IOError,
- "Can't get pin value");
- return NULL;
- }
- buf[0] = ret;
- buf[1] = '\0';
-
- return Py_BuildValue("s", buf);
-
-}
-
/** @brief Close port access
*
* @param aFdev as_gpio_device structure pointer
diff --git a/target/packages/as_devices/test_c.h b/target/packages/as_devices/test_c.h
index 9a1def3..6300126 100644
--- a/target/packages/as_devices/test_c.h
+++ b/target/packages/as_devices/test_c.h
@@ -438,8 +438,7 @@ void test_gpio()
struct as_gpio_device *gpio_dev;
int32_t ret;
int32_t value;
- char port_letter = 'F';
- int pin_num = 13;
+ int pin_num = 173; /* default F13 */
int port_direction = 0;
int port_value = 1;
int platform;
@@ -447,24 +446,21 @@ void test_gpio()
platform = as_helpers_get_platform();
switch (platform) {
case APF9328:
- port_letter = 'X';
pin_num = 0x007;
break;
case APF27:
- port_letter = 'F';
- pin_num = 13;
+ pin_num = 173;
break;
case APF51:
- port_letter = 'A';
pin_num = 3;
break;
default:
break;
}
- gpio_dev = as_gpio_open(port_letter, pin_num);
+ gpio_dev = as_gpio_open(pin_num);
if (gpio_dev == NULL)
{
- printf("Error can't open gpio %c\nHave you run loadgpio.sh ?\n", port_letter);
+ printf("Error can't open gpio %d\nHave you got gpiolib ?\n", pin_num);
pressEnterToContinue();
return ;
}
@@ -481,11 +477,10 @@ void test_gpio()
{
system("clear");
printf("**************************\n");
- printf(" Testing GPIO Port%c%d \n", port_letter, pin_num);
+ printf(" Testing GPIO Port%d \n", pin_num);
printf("**************************\n");
printf("Choose ('q' to quit):\n");
- printf(" 1) Change gpio (P%c%d)\n", as_gpio_get_port_letter(gpio_dev),
- as_gpio_get_pin_num(gpio_dev));
+ printf(" 1) Change gpio (%d)\n", as_gpio_get_pin_num(gpio_dev));
printf(" 2) Change direction (%s)\n", as_gpio_get_pin_direction(gpio_dev));
printf(" 3) Change value (%d)\n", as_gpio_get_pin_value(gpio_dev));
printf(" 4) Read pin value\n");
@@ -497,31 +492,17 @@ void test_gpio()
switch (buffer[0])
{
- case '1' : printf("Give letter of port in upper case : ");
- scanf("%s", buffer);
- if (buffer[0] != port_letter)
- {
- ret = as_gpio_close(gpio_dev);
- if(ret < 0)
- {
- printf("Error, can't close gpio\n");
- pressEnterToContinue();
- break;
- }
- }
- port_letter = buffer[0];
-
- printf("Give pin number : ");
+ case '1' : printf("Give pin number : ");
scanf("%d", &pin_num);
- gpio_dev = as_gpio_open(port_letter,pin_num);
+ gpio_dev = as_gpio_open(pin_num);
if (gpio_dev == NULL)
{
- printf("Error, can't open P%c%d\n", port_letter, pin_num);
+ printf("Error, can't open %d\n", pin_num);
pressEnterToContinue();
break;
}
- printf("Ok P%c%d is open\n", port_letter, pin_num);
+ printf("Ok %d is open\n", pin_num);
pressEnterToContinue();
break;
case '2' : printf("Give direction (in/out) : ");
hooks/post-receive
--
armadeus
|