当前位置:  编程技术>移动开发
本页文章导读:
    ▪I2C 的 四 个结构体        I2C 的 4 个结构体1, struct i2c_driver {  int id;  unsigned int class;  /* Notifies the driver that a new bus has appeared. This routine   * can be used by the driver to test if the bus meets its conditions   * & seek for the presence of.........
    ▪ Andriod Phonegap兑现系统推送        Andriod Phonegap实现系统推送 好了,首先我们来介绍一下用法: .js文件 4.修改plugin.xml(添加一条记录) ......
    ▪ Fedora14 源码安装qt4.7.0 PC版 和 arm版 过程 及有关问题解决(之三,续下)       Fedora14 源码安装qt4.7.0 PC版 和 arm版 过程 及问题解决(之三,续上)          接下来要编译qt4.7.0的Arm版本了!编译前确认安装了arm-linux-gcc,我的版本是4.5.1,试试看吧!以前4.3.2是没问题的! .........

[1]I2C 的 四 个结构体
    来源: 互联网  发布时间: 2014-02-18
I2C 的 4 个结构体
1,

struct i2c_driver {
 int id;
 unsigned int class;

 /* Notifies the driver that a new bus has appeared. This routine
  * can be used by the driver to test if the bus meets its conditions
  * & seek for the presence of the chip(s) it supports. If found, it
  * registers the client(s) that are on the bus to the i2c admin. via
  * i2c_attach_client.  (LEGACY I2C DRIVERS ONLY)
  */
 int (*attach_adapter)(struct i2c_adapter *);/*依附i2c_adapter函数指针 */

 int (*detach_adapter)(struct i2c_adapter *);/*脱离i2c_adapter函数指针*/

 /* tells the driver that a client is about to be deleted & gives it
  * the chance to remove its private data. Also, if the client struct
  * has been dynamically allocated by the driver in the function above,
  * it must be freed here.  (LEGACY I2C DRIVERS ONLY)
  */
 int (*detach_client)(struct i2c_client *); /*i2c client脱离函数指针*/

 /* Standard driver model interfaces, for "new style" i2c drivers.
  * With the driver model, device enumeration is NEVER done by drivers;
  * it's done by infrastructure.  (NEW STYLE DRIVERS ONLY)
  */
 int (*probe)(struct i2c_client *, const struct i2c_device_id *);
 int (*remove)(struct i2c_client *);

 /* driver model interfaces that don't relate to enumeration  */
 void (*shutdown)(struct i2c_client *);
 int (*suspend)(struct i2c_client *, pm_message_t mesg);
 int (*resume)(struct i2c_client *);

 /* a ioctl like command that can be used to perform specific functions
  * with the device.
  */
 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);//类似ioctl*/

 struct device_driver driver;/*设备驱动结构体*/

 const struct i2c_device_id *id_table;

 /* Device detection callback for automatic device creation */
 int (*detect)(struct i2c_client *, int kind, struct i2c_board_info *);
 const struct i2c_client_address_data *address_data;
 struct list_head clients;
};



#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)

/**
 
2.  * struct i2c_client - represent an I2C slave device
 * @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address;
 * I2C_CLIENT_PEC indicates it uses SMBus Packet Error Checking
 * @addr: Address used on the I2C bus connected to the parent adapter.
 * @name: Indicates the type of the device, usually a chip name that's
 * generic enough to hide second-sourcing and compatible revisions.
 * @adapter: manages the bus segment hosting this I2C device
 * @driver: device's driver, hence pointer to access routines
 * @dev: Driver model device node for the slave.
 * @irq: indicates the IRQ generated by this device (if any)
 * @list: list of active/busy clients (DEPRECATED)
 * @detected: member of an i2c_driver.clients list
 * @released: used to synchronize client releases & detaches and references
 *
 * An i2c_client identifies a single device (i.e. chip) connected to an
 * i2c bus. The behaviour exposed to Linux is defined by the driver
 * managing the device.
 */
struct i2c_client {
 unsigned short flags;  /* div., see below  *//标志
 unsigned short addr;  /* chip address - NOTE: 7bit *///低7位为芯片地址
     /* addresses are stored in the */
     /* _LOWER_ 7 bits  */
 char name[I2C_NAME_SIZE];//设备名称
 struct i2c_adapter *adapter; /* the adapter we sit on */依附的i2c_adapter
 struct i2c_driver *driver; /* and our access routines */依附的i2c_driver
 struct device dev;  /* the device structure  */
 int irq;   /* irq issued by device  */分配给设备的中断号
 struct list_head list;  /* DEPRECATED */
 struct list_head detected;
 struct completion released;//用于同步
};
 

3.


struct i2c_algorithm {
 /* If an adapter algorithm can't do I2C-level access, set master_xfer
    to NULL. If an adapter algorithm can do SMBus access, set
    smbus_xfer. If set to NULL, the SMBus protocol is simulated
    using common I2C messages */
 /* master_xfer should return the number of messages successfully
    processed, or a negative value on error */
 int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs,
      int num); /*i2c传输函数指针*/

 int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr,/*smbus传输函数指针*/

      unsigned short flags, char read_write,
      u8 command, int size, union i2c_smbus_data *data);
 /* To determine what the adapter supports */
 u32 (*functionality) (struct i2c_adapter *);/*返回适配器支持的功能*/
};
 
 
4.



struct i2c_adapter {
 struct module *owner; //所属模块
 unsigned int id; //algorithm 的类型 ,定义于i2c_id.h,I2C_ALGO_*****
 unsigned int class;    /* classes to allow probing for */
 const struct i2c_algorithm *algo; /* the algorithm to access the bus */总线的通信方法结构体指针
 void *algo_data; //algorithm 私有数据
 /* --- administration stuff. */
 int (*client_register)(struct i2c_client *);  //client 注册时调用
 int (*client_unregister)(struct i2c_client *);//client 注销时调用
 /* data fields that are valid for all devices */
 u8 level;    /* nesting level for lockdep */
 struct mutex bus_lock;/*控制并发访问的自旋锁*/
 struct mutex clist_lock;
 int timeout;
 int retries; //重试次数
 struct device dev;  /* the adapter device */ //适配器设备
 int nr;
 struct list_head clients; /* DEPRECATED * /* client链表头*/
/
 char name[48]; //适配器名称
 struct completion dev_released;  //用于同步
}
 
 struct i2c_msg {
2 __u16 addr; /* 设备地址*/
3 __u16 flags; /* 标志 */ 
4 __u16 len; /* 消息长度*/
5 __u8 *buf; /* 消息数据*/
6 };

    
[2] Andriod Phonegap兑现系统推送
    来源: 互联网  发布时间: 2014-02-18
Andriod Phonegap实现系统推送

花了不少的时间研究phonegap,希望能够找出一个能够取代轮询的推送方式,尝试了pushwoosh之后发现有两个问题,一个是手机必须集成有andriod apis的组件,其次不知道是不是什么原因总是有account失败的错误,实在是没有办法,想想即便解决了,第一个问题依然难以解决。

后来在江哥的推荐下找到了一个系统推送的phonegap插件

好了,首先我们来介绍一下用法:

1.(两个最关键的文件(.java和.js组件))

/*
*
* Copyright (C) 2011 Dmitry Savchenko <dg.freak@gmail.com>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/

package com.tricedesigns;

import org.apache.cordova.api.PluginResult.Status;
import org.json.JSONArray;
import org.json.JSONException;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;


public class StatusBarNotification extends Plugin {
	//	Action to execute
	public static final String NOTIFY = "notify";
	public static final String CLEAR = "clear";
	
	/**
	 * 	Executes the request and returns PluginResult
	 * 
	 * 	@param action		Action to execute
	 * 	@param data			JSONArray of arguments to the plugin
	 *  @param callbackId	The callback id used when calling back into JavaScript
	 *  
	 *  @return				A PluginRequest object with a status
	 * */
	@Override
	public PluginResult execute(String action, JSONArray data, String callbackId) {
		String ns = Context.NOTIFICATION_SERVICE;
		mNotificationManager = (NotificationManager) ctx.getSystemService(ns);
        context = ctx.getApplicationContext();
		
		PluginResult result = null;
		if (NOTIFY.equals(action)) {
			try {

				String title = data.getString(0);
				String body = data.getString(1);
				Log.d("NotificationPlugin", "Notification: " + title + ", " + body);
				showNotification(title, body);
				result = new PluginResult(Status.OK);
			} catch (JSONException jsonEx) {
				Log.d("NotificationPlugin", "Got JSON Exception "
						+ jsonEx.getMessage());
				result = new PluginResult(Status.JSON_EXCEPTION);
			}
		} else if (CLEAR.equals(action)){
			clearNotification();
		} else {
			result = new PluginResult(Status.INVALID_ACTION);
			Log.d("NotificationPlugin", "Invalid action : "+action+" passed");
		}
		return result;
	}

	/**
	 * 	Displays status bar notification
	 * 
	 * 	@param contentTitle	Notification title
	 *  @param contentText	Notification text
	 * */
	public void showNotification( CharSequence contentTitle, CharSequence contentText ) {
		int icon = R.drawable.nofication;
        long when = System.currentTimeMillis();
        
        Notification notification = new Notification(icon, contentTitle, when);
	//notification.flags |= Notification.FLAG_NO_CLEAR; //Notification cannot be clearned by user
	
	Intent notificationIntent = new Intent((Context) ctx, ctx.getClass());
        PendingIntent contentIntent = PendingIntent.getActivity((Context) ctx, 0, notificationIntent, 0);
        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
        
        mNotificationManager.notify(1, notification);
	}
	
	/**
	 * Removes the Notification from status bar
	 */
	public void clearNotification() {
		mNotificationManager.cancelAll();
	}
	
	private NotificationManager mNotificationManager;
    private Context context;
}


.js文件

/*
*
* Copyright (C) 2011 Dmitry Savchenko <dg.freak@gmail.com>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
 
/**
 *  
 *  Constructor
 */
var NotificationMessenger = { 
        notify:function(title, body) {
            return cordova.exec(null, null, 'StatusBarNotification','notify', [title, body]);
        },
        clear:function() {
            return cordova.exec(null, null, 'StatusBarNotification', 'clear', []);
        },
         
 
 
}


3.记得放入一张notification.png的图片在res下的drawable文件夹下

4.修改plugin.xml(添加一条记录)

<plugin name="StatusBarNotification" value="com.tricedesigns.StatusBarNotification"/>

5.定义调用的函数

function aaa(){
        NotificationMessenger.notify("CF西西", "Phonegap Andriod 交流 QQ 群 250395324欢迎您的加入");
    }

6.ok,找个按钮触发这个aaa函数,然后运行一下你会看到如下效果(项目代码可去我的qq群共享下载哦250395324)




    
[3] Fedora14 源码安装qt4.7.0 PC版 和 arm版 过程 及有关问题解决(之三,续下)
    来源: 互联网  发布时间: 2014-02-18
Fedora14 源码安装qt4.7.0 PC版 和 arm版 过程 及问题解决(之三,续上)

          接下来要编译qt4.7.0的Arm版本了!编译前确认安装了arm-linux-gcc,我的版本是4.5.1,试试看吧!以前4.3.2是没问题的!

     将原来的解压缩目录删除了,因为pc上的qt已经装好了。然后mkdir arm-qt4.7.0,将源文件解压缩到这个文件夹下。命令:tar -zxvf qt-everywhere-opensource-src-4.7.0.tar.gz -C ./arm-qt4.7.0

然后,cd arm-qt4.7.0/ ;qt-everywhere-opensource-src-4.7.0/;大致思路依旧如“Fedora14 源码安装qt4.7.0 PC版 和 arm版 过程 及问题解决”第一篇里的三步。

一、

     cd /usr/local/Trolltech/;

[root@localhost Trolltech]# ls
Qt-4.7.0  QtCreator
[root@localhost Trolltech]# mkdir arm-Qt-4.7.0

先创建个arm-Qt-4.7.0,这是arm版的qt4.7.0安装位置。

命令:echo yes |./configure -prefix /usr/local/Trolltech/arm-Qt-4.7.0 -opensource -embedded arm -xplatform qws/linux-arm-g++ -no-webkit -qt-libtiff -qt-libmng -qt-mouse-tslib -qt-mouse-pc -no-mouse-linuxtp -no-neon

就可以configure了,configure主要参数说明:

-embeded arm:表示将编译针对arm平台的embedded版本

-xplatform qws/linux-arm-g++:  表示使用arm-linux交叉编译器进行编译

-qt-mouse-tslib:使用tslib驱动触摸屏

-prefix /usr/local/Trolltech/arm-Qt-4.7.0 : 表示arm版的qt最终安装位置,注意移植的时候也要再目标板的文件系统中创建相同文件夹,部署到板子上的相同路径。

二、make

三、make install

一路下来没有问题。

接下来就是要将编译好的arm-Qt-4.7.0拷贝到目标板子上了,由于快捷方式不好拷贝,这里先将其压缩,将压缩文件拷贝到板子里,在终端就行解压缩就Ok了。ls -lh 。。。查看文件大小,压缩包才31M。

奶奶的,没想到解压缩到板子上的时候总是提示错误如下:

arm-Qt-4.7.0/examples/sql/drilldown/
arm-Qt-4.7.0/examples/sql/drilldown/view.cpp
arm-Qt-4.7.0/examples/sql/drilldown/imageitem.h
arm-Qt-4.7.0/examples/sql/drilldown/images/
arm-Qt-4.7.0/examples/sql/drilldown/images/berlin.png
arm-Qt-4.7.0/examples/sql/drilldown/images/redwood.png
arm-Qt-4.7.0/examples/sql/drilldown/images/beijing.png
arm-Qt-4.7.0/examples/sql/drilldown/images/brisbane.png
arm-Qt-4.7.0/examples/sql/drilldown/images/oslo.png
arm-Qt-4.7.0/examples/sql/drilldown/images/munich.png
arm-Qt-4.7.0/examples/sql/drilldown/drilldown.pro
arm-Qt-4.7.0/examples/sql/drilldown/view.h
tar: write error: No space left on device

说我的空间不够了!不知道咋回事,重复了两次还是这,删除了板子里的一些东西 还是在解压缩examples这块卡住了。连师父给我的U盘都差点搞报废了,还是没报废 ,嘿嘿。。。。。。。。。。一气之下,将生成的arm-Qt-4.7.0下的examples全删了,然后建tar包,再拷过去解压缩到板子上的对等位置。这次通过了。

我忽然想到,在编译arm的qt库的时候,configure里是可以设置的,我竟然忘了,因为移植的时候是不需要examples、docs、demo这些没用的东西的,而且不需要支持qt3,竟白浪费这么多空间和时间!因此,更改后的编译arm版的qt库的configure命令为:

echo yes |./configure -prefix /usr/local/Trolltech/arm-Qt-4.7.0 -opensource -embedded arm -xplatform qws/linux-arm-g++ -no-webkit -qt-libtiff -qt-libmng -qt-mouse-tslib -qt-mouse-pc -no-mouse-linuxtp -no-neon -nomake examples -nomake docs -nomake demos -nomake tools -no-qt3support 

    接下来,在板子的终端里设置环境变量:

设置环境变量 板子里:
export QTDIR=/usr/local/Trolltech/arm-Qt-4.7.0
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH

可借鉴http://bbs.witech.com.cn/thread-9966-1-1.html,点tools的options将arm版的qmake添加进去,然后添加一个gcce,选中arm-linux-gcc或者arm-linux-g++ 的路径。但遗憾的是,设置完了之后,依然无法再qtcreator下 直接编译、调用arm版的qmake。

真操蛋!只能手动将原工作空间里的文件夹拷贝出来,拷贝到一个arm-qtWorkspace的工作空间下,然后进去:

/usr/local/Trolltech/arm-Qt-4.7.0/bin/qmake -project

/usr/local/Trolltech/arm-Qt-4.7.0/bin/qmake

make

如此三步,生成可执行文件!






    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android提高之自定义Menu(TabMenu)实现方法 iis7站长之家
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3