第一篇:嵌入式Linux系統(tǒng)下I2C設(shè)備驅(qū)動程序的開發(fā)(范文模版)
嵌入式Linux系統(tǒng)下I2C設(shè)備驅(qū)動程序的開發(fā)
【摘 要】 I2C總線是一種很通用的總線,具有簡單、高效等特點,廣泛應(yīng)用在各種消費類電子產(chǎn)品及音視頻設(shè)備上,在嵌入式系統(tǒng)的開發(fā)中也經(jīng)常用到。本文分析了嵌入式 linux系統(tǒng)中I2C驅(qū)動程序的結(jié)構(gòu),并結(jié)合一個具體的I2C時鐘芯片DS1307,說明在嵌入式linux系統(tǒng)下開發(fā)I2C設(shè)備驅(qū)動程序的一般流程。【關(guān)鍵字】I2C總線 嵌入式linux 驅(qū)動開發(fā)
1、I2C總線簡介 I2C(Inter-Integrated Circuit)總線是一種由PHILIPS公司開發(fā)的兩線式串行總線,用于連接微控制器及其外圍設(shè)備。I2C總線最主要的優(yōu)點就是簡單性和有效性。
1.1 I2C總線工作原理
I2C總線是由數(shù)據(jù)線SDA和時鐘SCL構(gòu)成的串行總線,各種被控制器件均并聯(lián)在這條總線上,每個器件都有一個唯一的地址識別,可以作為總線上的一個發(fā)送器件或接收器件(具體由器件的功能決定)[1]。I2C總線的接口電路結(jié)構(gòu)如圖1所示。
圖1 I2C總線接口電路[1] 1.2 I2C總線的幾種信號狀態(tài)[1]
1.空閑狀態(tài):SDA和SCL都為高電平。2.開始條件(S):SCL為高電平時,SDA由高電平向低電平跳變,開始傳送數(shù)據(jù)。3.結(jié)束條件(P):SCL為低電平時,SDA 由低電平向高電平跳變,結(jié)束傳送數(shù)據(jù)。
4.數(shù)據(jù)有效:在SCL的高電平期間,SDA保持穩(wěn)定,數(shù)據(jù)有效。SDA的改變只能發(fā)生在SCL的底電平期間。
5.ACK信號: 數(shù)據(jù)傳輸?shù)倪^程中,接收器件每接收一個字節(jié)數(shù)據(jù)要產(chǎn)生一個ACK信號,向發(fā)送器件發(fā)出特定的低電平脈沖,表示已經(jīng)收到數(shù)據(jù)。1.3 I2C總線基本操作
I2C總線必須由主器件(通常為微控制器)控制,主器件產(chǎn)生串行時鐘(SCL),同時控制總線的傳輸方向,并產(chǎn)生開始和停止條件。
數(shù)據(jù)傳輸中,首先主器件產(chǎn)生開始條件,隨后是器件的控制字節(jié)(前七位是從器件的地址,最后一位為讀寫位)。接下來是讀寫操作的數(shù)據(jù),以及 ACK響應(yīng)信號。數(shù)據(jù)傳輸結(jié)束時,主器件產(chǎn)生停止條件[1]。具體的過程如圖2所示。
圖2 完整的I2C數(shù)據(jù)傳輸過程[1] 2.Linux下I2C驅(qū)動程序的分析 2.1 Linux系統(tǒng)I2C驅(qū)動的層次結(jié)構(gòu)
Linux系統(tǒng)對I2C設(shè)備具有很好的支持,Linux系統(tǒng)下的I2C驅(qū)動程序從邏輯上可以分為3個部分:
1.I2C總線的驅(qū)動 I2C core :實現(xiàn)對I2C總線、I2C adapter及I2C driver的管理。2.I2C控制器的驅(qū)動 I2C adapter :針對不同類型的I2C控制器,實現(xiàn)對I2C總線訪問的具體方法。
3.I2C設(shè)備的驅(qū)動 I2C driver :針對特定的I2C設(shè)備,實現(xiàn)具體的功能,包括read, write以及ioctl等對用戶層操作的接口。這三個部分的層次關(guān)系如圖3和圖4所示。
2.2 I2C 總線驅(qū)動 I2C core
I2C core是Linux內(nèi)核用來維護(hù)和管理的I2C的核心部分,其中維護(hù)了兩個靜態(tài)的List,分別記錄系統(tǒng)中的I2C driver結(jié)構(gòu)和I2C adapter結(jié)構(gòu)。I2C core提供接口函數(shù),允許一個I2C adatper,I2C driver和I2C client初始化時在I2C core中進(jìn)行注冊,以及退出時進(jìn)行注銷。同時還提供了I2C總線讀寫訪問的一般接口(具體的實現(xiàn)在與I2C控制器相關(guān)的I2C adapter中實現(xiàn)),主要應(yīng)用在I2C設(shè)備驅(qū)動中。
2.3 I2C控制器的驅(qū)動 I2C adapter
I2C adapter是針對不同類型I2C控制器硬件,實現(xiàn)比較底層的對I2C總線訪問的具體方法。I2C adapter 構(gòu)造一個對I2C core層接口的數(shù)據(jù)結(jié)構(gòu),并通過接口函數(shù)向I2C core注冊一個控制器。I2C adapter主要實現(xiàn)對I2C總線訪問的算法,iic_xfer()函數(shù)就是I2C adapter底層對I2C總線讀寫方法的實現(xiàn)。同時I2C adpter 中還實現(xiàn)了對I2C控制器中斷的處理函數(shù)。
2.4 I2C設(shè)備的驅(qū)動 I2C driver
I2C driver中提供了一個通用的I2C設(shè)備的驅(qū)動程序,實現(xiàn)了字符類型設(shè)備的訪問接口,對設(shè)備的具體訪問是通過I2C adapter來實現(xiàn)的。I2C driver構(gòu)造一個對I2C core層接口的數(shù)據(jù)結(jié)構(gòu),通過接口函數(shù)向 I2C Core注冊一個I2C設(shè)備驅(qū)動。同時I2C driver 構(gòu)造一個對用戶層接口的數(shù)據(jù)結(jié)構(gòu),并通過接口函數(shù)向內(nèi)核注冊為一個主設(shè)備號為89的字符類型設(shè)備。
I2C driver實現(xiàn)用戶層對I2C設(shè)備的訪問,包括open,read,write,ioctl,release等常規(guī)文件操作,我們可以通過open函數(shù) 打開 I2C的設(shè)備文件,通過ioctl函數(shù)設(shè)定要訪問從設(shè)備的地址,然后就可以通過 read和write函數(shù)完成對I2C設(shè)備的讀寫操作。
通過I2C driver提供的通用方法可以訪問任何一個I2C的設(shè)備,但是其中實現(xiàn)的read,write及ioctl等功能完全是基于一般設(shè)備的實現(xiàn),所有的操作 數(shù)據(jù)都是基于字節(jié)流,沒有明確的格式和意義。為了更方便和有效地使用I2C設(shè)備,我們可以為一個具體的I2C設(shè)備開發(fā)特定的I2C設(shè)備驅(qū)動程序,在驅(qū)動中 完成對特定的數(shù)據(jù)格式的解釋以及實現(xiàn)一些專用的功能。3.一個具體的I2C設(shè)備驅(qū)動程序的開發(fā)
DS1307是一款小巧的I2C接口的實時時鐘芯片,具有低功耗,全BCD碼時鐘和日歷輸出,12 /24小時工作模式,時分秒、星期、年月日計時數(shù)據(jù),潤年自動補償,有效期至2100年,外加56 Bytes的NV RAM(非易失性的RAM)等特點[3]。下面以DS1307為例,說明一個具體的I2C設(shè)備驅(qū)動程序的設(shè)計要點。3.1 I2C設(shè)備驅(qū)動程序的一般結(jié)構(gòu)
一個具體的I2C設(shè)備驅(qū)動需要實現(xiàn)兩個方面的接口,一個是對I2C core層的接口,用以掛接I2C adapter層來實現(xiàn)對I2C總線及I2C設(shè)備具體的訪問方法,包括要實現(xiàn)attach_adapter,detach_client,command 等接口函數(shù)。另一個是對用戶應(yīng)用層的接口,提供用戶程序訪問I2C設(shè)備的接口,包括實現(xiàn)open,release,read,write以及最重要的 ioctl等標(biāo)準(zhǔn)文件操作的接口函數(shù)。對I2C core層的接口函數(shù)的具體功能解釋如下: attach_adapter:I2C driver在調(diào)用I2C_add_driver()注冊時,對發(fā)現(xiàn)的每一個I2C adapter(對應(yīng)一條I2C 總線)都要調(diào)用該函數(shù),檢查該I2C adapter是否符合I2C driver的特定條件,如果符合條件則連接此I2C adapter,并通過I2C adapter來實現(xiàn)對I2C總線及I2C設(shè)備的訪問。
detach_client:I2C driver在刪除一個I2C device時調(diào)用該函數(shù),清除描述這個I2C device的數(shù)據(jù)結(jié)構(gòu),這樣以后就不能訪問該設(shè)備了。
command:針對設(shè)備的特點,實現(xiàn)一系列的子功能,是用戶接口中的ioctl功能的底層實現(xiàn)。
3.2 DS1307驅(qū)動程序?qū)崿F(xiàn)對I2C core層的接口
在驅(qū)動中必須實現(xiàn)一個struct i2c_driver 的數(shù)據(jù)結(jié)構(gòu),并在驅(qū)動模塊初始化時向I2C core注冊一個I2C驅(qū)動,并完成對I2C adapter的相關(guān)操作。struct i2c_driver ds1307_driver = { name: “DS1307”, id: I2C_DRIVERID_DS1307, flags: I2C_DF_NOTIFY, attach_adapter:ds1307_probe, detach_client:ds1307_detach, command: ds1307_command };數(shù)據(jù)結(jié)構(gòu)ds1307_driver中的name:“DS1307”,Id:I2C_DRIVERID_DS1307用來標(biāo)識DS1307驅(qū)動程序。flags: I2C_DF_NOTIFY表示在I2C總線發(fā)生變化時通知該驅(qū)動。
ds1307_probe對應(yīng)i2c_driver數(shù)據(jù)結(jié)構(gòu)中的attach_adapter,主要功能:調(diào)用 I2C core 層提供的i2c_probe函數(shù)查找一條I2C總線,看是否有DS1307的設(shè)備存在,如果存在DS1307,則將對應(yīng)的I2C adapter 和DS1307設(shè)備掛接在一起,并通過該I2C adapter來實現(xiàn)對DS1307的訪問。同時使能DS1307, 并調(diào)用i2c_attach_client()向I2C core層注冊DS1307。
ds1307_detach對應(yīng)i2c_driver數(shù)據(jù)結(jié)構(gòu)中的detach_client,主要功能:調(diào)用i2c_detach_client()向I2C core層注銷DS1307,并不使能DS1307,這樣I2C驅(qū)動就不能訪問DS1307了。
ds1307_command對應(yīng)i2c_driver 數(shù)據(jù)結(jié)構(gòu)中的command,主要功能:針對DS1307時鐘芯片的特點,實現(xiàn)一系列的諸如DS1307_GETTIME,DS1307_SETTIME,DS1307_GETDATETIME,DS1307_MEM_READ,DS1307_MEM_WRITE等子功能,是用戶接口中的ioctl功能的底層實現(xiàn)。
以上3個接口函數(shù)使DS1307的驅(qū)動程序?qū)崿F(xiàn)了對I2C 總線及I2C adpater的掛接,因此就可以通過I2C core的提供對I2C總線讀寫訪問的通用接口,來開發(fā)實現(xiàn)DS1037驅(qū)動程序?qū)τ脩魬?yīng)用層的接口函數(shù)。3.3 DS1307驅(qū)動程序?qū)崿F(xiàn)對用戶應(yīng)用層的接口
在驅(qū)動中必須實現(xiàn)一個struct file_operations 的數(shù)據(jù)結(jié)構(gòu),并向內(nèi)核注冊為一個字符類型的設(shè)備(用單獨的主設(shè)備號來標(biāo)識),或者注冊為一個miscdevice設(shè)備(所有miscdevice設(shè)備共同 一個主設(shè)備號,不同的次設(shè)備號,所有的miscdevice設(shè)備形成一個鏈表,對設(shè)備訪問時根據(jù)次設(shè)備號查找對應(yīng)的miscdevice設(shè)備,然后調(diào)用其 struct file_operations中注冊的應(yīng)用層接口進(jìn)行操作)。
struct file_operations rtc_fops = { owner: THIS_MODULE, ioctl: ds1307_rtc_ioctl, read: ds1307_rtc_read, write: ds1307_rtc_read, open: ds1307_rtc_open, release: ds1307_rtc_release };數(shù)據(jù)結(jié)構(gòu)rtc_fops 中的ds1307_rtc_open 和ds1307_rtc_release對應(yīng)file_operations中的open和release,分別用來打開和關(guān)閉DS1307。ds1307_rtc_ioctl對應(yīng)file_operations中的ioctl,對用戶提供的一系列控制時鐘芯片的具體命 令:RTC_GET_TIME: 以固定的數(shù)據(jù)格式讀取實時時鐘的時間。RTC_SET_TIME:以固定的數(shù)據(jù)格式設(shè)定實時時鐘的時間。RTC_SYNC_TIME:系統(tǒng)時鐘和實時時鐘 之間的時間同步。
ds1307_rtc_read 對應(yīng)對應(yīng)file_operations中的read,實現(xiàn)與ds1307_rtc_ioctl 的子功能RTC_GET_TIME相同的功能,以及從NV RAM讀取數(shù)據(jù)。
ds1307_rtc_write 對應(yīng)file_operations中的write,實現(xiàn)與ds1307_rtc_ioctl的子功能 RTC_SET_TIME相同的功能,以及將數(shù)據(jù)寫入NV RAM。3.4 DS1307驅(qū)動程序的加載和測試
在DS1307驅(qū)動模塊的初始化函數(shù)ds1307_init()中,首先通過i2c_add_driver(&ds1307_driver)向I2C core層注冊一個I2C的設(shè)備驅(qū)動,然后再通過misc_register(&ds1307_rtc_miscdev)將DS1307注冊為一個miscdevice設(shè)備,這樣用戶程序就可以通過主設(shè)備號10 次設(shè)備號 135的設(shè)備節(jié)點/dev/rtc來訪問DS1307了。
將DS1307的驅(qū)動程序編譯成模塊的方式,通過insmod命令加載進(jìn)內(nèi)核,然后用測試代碼進(jìn)行測試,DS1307驅(qū)動程序中實現(xiàn)的所有功能都達(dá)到了預(yù)期的效果。由于DS1307驅(qū)動程序在底層實現(xiàn)了對DS1307時鐘芯片數(shù)據(jù)的解釋和轉(zhuǎn)換,所以在用戶程序中得到的就是有固定格式和意義的數(shù)據(jù),這樣就方便了用戶程序的訪問,提高了應(yīng)用開發(fā)的效率。4.總結(jié)
I2C總線是一種結(jié)構(gòu)小巧,協(xié)議簡單的總線,應(yīng)用很廣泛,訪問起來簡單方便。linux系統(tǒng)下I2C的驅(qū)動程序具有清晰的層次結(jié)構(gòu),可以很容易地為一個特 定的I2C設(shè)備開發(fā)驅(qū)動。本文通過對linux系統(tǒng)下I2C驅(qū)動,以及一個具體的DS1307時鐘芯片驅(qū)動結(jié)構(gòu)的分析,基本上可以很清楚看出一個I2C設(shè) 備驅(qū)動的開發(fā)過程。實現(xiàn)的關(guān)鍵分為兩個部分,1.對I2C core的接口,必須實現(xiàn) struct i2c_drvier 數(shù)據(jù)結(jié)構(gòu)中的幾個特定的功能函數(shù)。這些函數(shù)是I2C驅(qū)動與I2C總線物理層(I2C控制器)和I2C設(shè)備器件之間通信的基礎(chǔ)。2.對用戶應(yīng)用層的接口,必須實現(xiàn)struct file_operation數(shù)據(jù)結(jié)構(gòu)中的一些特定功能的函數(shù),如 open,release , read ,write,lseek等函數(shù)。以上兩類接口中,對I2C core的接口是對I2C設(shè)備訪問的基礎(chǔ),實現(xiàn)對I2C總線具體的訪問方法;對用戶應(yīng)用層的接口則是方便應(yīng)用程序開發(fā),實現(xiàn)設(shè)備特定功能的必不可少的部 分。參考文獻(xiàn):
[1] Philips Corporation,I2C bus specification version 2.1,2000 [2] Linux kernel,version 2.4.30 [3] Maxim Integrated Products , inc.USA.DS1307 Datasheet , 2004 [4] Aless and Robin著,魏永明等譯,《LINUX設(shè)備驅(qū)動程序(第二版)》,北京,中國電力出版社,2004年
第二篇:linux設(shè)備驅(qū)動程序開發(fā)總結(jié)
不管我們學(xué)習(xí)什么編程語言,和我們見面的第一個程序就是“hello world!” 相信各位道上的朋友都遇到過這種個程序!
學(xué)習(xí)驅(qū)動程序也不例外,我學(xué)的第一個驅(qū)動程序就是“hello world!” 具體的程序代碼如下:
#include
#include
MODULE_LICENSE(“Dual BSD/GPL”);
static int hello_init(void)
{
printk(KERN_ALERT“Hello, world!n”);
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT“byby FriendyARM mini2440!n”);
}
module_init(hello_init);
module_exit(hello_exit);
將其復(fù)制到工作目錄下,并編寫一個簡單的Makefile文件:
由于每個人使用的Linux系統(tǒng)不一樣且每個人內(nèi)核源代碼所存放的位置也不是一樣的。所以編寫Makefile文件的時候,參考別人的進(jìn)行修改是一個很不錯的的學(xué)習(xí)Makefile文件的方法。當(dāng)然你能把Linux內(nèi)核的Makefile文件了解一下,對你了解Linux內(nèi)核有很大的幫助的。
學(xué)習(xí)心得:
1、驅(qū)動模塊運行在內(nèi)核空間,運行是不能依賴任何函數(shù)庫和模塊連接,所以在寫驅(qū)動程序的時候
所調(diào)用的函數(shù)只能是作為內(nèi)核一部分的函數(shù)。
2、驅(qū)動模塊和應(yīng)用程序的一個重要不同是:應(yīng)用程序退出時可不管資源釋放或者其他的清除
工作,但模塊的退出啊哈念書必須仔細(xì)撤銷初始化函數(shù)所做的一切,否則,在系統(tǒng)想重新引導(dǎo)之前某些
東西就會殘留在系統(tǒng)中。
3、處理器的多種工作模式其實就是為了操作系統(tǒng)的用戶空間和內(nèi)核空間設(shè)計的,在Unix類的操作系統(tǒng)
中只是用到了兩個級別:最高級別和最低級別。
4、要十分注意驅(qū)動程序的并發(fā)處理。在Linux驅(qū)動程序中必須解決的一個問題就是多個進(jìn)程對共享資源的并發(fā)訪問.Linux對解決并發(fā)訪問可能導(dǎo)致的竟態(tài)問題提供了幾種機制:中斷屏蔽、原子操作、自旋鎖、信號量等機制。
5、內(nèi)核API中具有下劃線(__)的函數(shù),通常是接口的底層組件,應(yīng)該慎用。
6、內(nèi)核代碼不能實現(xiàn)浮點運算。內(nèi)核中沒有提供一套進(jìn)行浮點運算的完整的環(huán)境。
7、Makefile文件的分析:
obj-m := hello.o 代表了我們要構(gòu)建的模塊名為hello.ko,make會子啊該目錄下自動找到hello.c文件進(jìn)行編譯。如果hello.o文件是有其他的源文件生成(比如file.1和file1.c)的,則在下面加上:
hello-objs := file.o file1.o......(其中用紅色標(biāo)志的是對應(yīng)關(guān)系)$(MAKE)-C $(KERNELDIR)M=$(PWD)modules
其中-C $(KERNELDIR)指定了內(nèi)核源代碼的位置,其中保存有內(nèi)核的頂層makefile文件。
M=$(PWD)指定了模塊源代碼的位置
modules 目標(biāo)指向obj-m變量中設(shè)定的模塊
8、insmod使用公共內(nèi)核符號表來解析模塊中未定義的符號,公共內(nèi)核符號表中包含了的、所有的全局內(nèi)核項(即函數(shù)和變量的地址),這是實現(xiàn)模塊化驅(qū)動程序所必須的。
9、Linux使用模塊層疊技術(shù),我們可以將模塊劃分為多個層次,通過簡化每個層可以縮短開發(fā)周期。如果一個模塊需要向其他模塊導(dǎo)出符號,則使用下面宏:
EXPORT_SYMBOL(name);
EXPORT_SYMBOL_GPL(name);
符號必須子啊模塊文件的全局變量部分導(dǎo)出,因為這兩個宏將被擴展為一個特殊變量的聲明,而該變量必須是全局的。
10、所有的模塊代碼都必須包含下面兩個頭文件:
#include
#include
11、所有模塊代碼都應(yīng)指定所使用的許可證:
MODULE_LICENSE(“Dual BSD/GPL”);
12、初始化和關(guān)閉
初始化的實際定義通常是:
staticint _ _init initialization_function(void)
{
/*初始化代碼*/
}
module_init(initialization_function)
清除函數(shù)的實際定義是:
static int _ _exit cleanup_function(void)
{
/*清除代碼*/
}
module_exit(cleanup_function)
13、還有一些是可選的其他的描述型的定義:
MODULE_AUTHOR(“");
MODULE_DESCRIPTION(”“);
MODULE_VERSION(”“);
MODULE_ALIAS(”“);
MODULE_DEVICE_TABLE(”");
這些模塊的聲明習(xí)慣性的放在模塊程序的最后面。
14、Linux內(nèi)核模塊的初始化出錯處理一般使用“goto”語句,通常情況下很少使用“goto”,但是出錯處理是(可能是唯一的情況),它卻非常的有用。
在大一學(xué)習(xí)C語言的時候,老師就建議不要使用“goto”語句,并說很少會用到,在這里遇到第一個建議使用“goto”語句的。在追求效率的代碼中使用goto語句一直是最好的錯誤恢復(fù)機制。下面是我截下來的一段關(guān)于使用goto語句實現(xiàn)錯誤處理的程序:
struct something*item1;
struct somethingelse*item2;
int stuff_ok;
void my_cleanup(void)
{
if(item1)
release_thing(item1);
if(item2)
release_thing2(item2);
if(stuff_ok)
unregister_stuff();
return;
}
int __init my_init(void)
{
int err=-ENOMEM;
item1= allocate_thing(arguments);item2= allocate_thing2(arguments2);if(!item2||!item2)
goto fail;
err= register_stuff(item1, item2);if(!err)
stuff_ok= 1;
else
goto fail;
return 0;/* success*/
fail:
my_cleanup();
return err;
}
第三篇:嵌入式開發(fā)實訓(xùn)室設(shè)備維修制度
嵌入式開發(fā)實訓(xùn)室設(shè)備維修制度
為做好分院實驗室儀器設(shè)備的維修管理工作,確保實驗室儀器設(shè)備的完好,特制定本制度。
一、儀器設(shè)備的使用管理人員應(yīng)熟悉儀器設(shè)備,會正確操作使用,平時要做到精心維護(hù),認(rèn)真保養(yǎng),加強檢查,及時排除隱患。
二、儀器設(shè)備維護(hù)保養(yǎng)要根據(jù)其性能進(jìn)行,認(rèn)真做好防銹、防火、防潮、防震工作,同時還應(yīng)做好清潔潤滑、緊固、通電、更換易損零部件等工作。
三、儀器設(shè)備出現(xiàn)故障隱患苗頭時,應(yīng)停止使用,及時檢查,并做好安全檢查記錄。
四、儀器設(shè)備的維修必須在認(rèn)真做好故障診斷記錄的基礎(chǔ)上,由管理人員向分院提出維修申請報告,經(jīng)批準(zhǔn)后,方可進(jìn)行修理。儀器設(shè)備的修理采取鼓勵校內(nèi)修理,控制校外修理,盡可能減少異地修理。
五、儀器設(shè)備修理后,必須組織有關(guān)專業(yè)技術(shù)人員進(jìn)行測試鑒定,并寫出鑒定結(jié)論,經(jīng)確定為合格后方可投入正常使用。
六、儀器設(shè)備的維修記錄,應(yīng)妥善保管,不得丟失。
七、實驗室各類技術(shù)人員都要認(rèn)真學(xué)習(xí)修理技術(shù),增強修理能力,做到儀器設(shè)備的一般故障,本室即可排除。
電子與信息工程分院2012年8月29日
第四篇:基于嵌入式ARM平臺的遠(yuǎn)程IO數(shù)據(jù)采集系統(tǒng)的研究和開發(fā).
Research and Development of the Remote I/O Data Acquisition System Based on Embedded ARM Platform
INTRODUCTION
With the wide use of the networked, intelligent and digital distributed control system, the data acquisition system based on the single-chip is not only limited in processing capacity, but also the problem of poor real-time and reliability.In recent years, with the rapid development of the field of industrial process control and the fast popularization of embedded ARM processor, it has been a trend that ARM processor can substitute the single-chip to realize data acquisition and control.Embedded ARM system can adapt to the strict requirements of the data acquisition system, such as the function, reliability, cost, size, power consumption, and so on.In this paper, a new kind of remote I/O data acquisition system based on ARM embedded platform has been researched and developed, which can measure all kinds of electrical and thermal parameters such as voltage, current, thermocouple, RTD, and so on.The measured data can be displayed on LCD of the system, and at the same time can be transmitted through RS485 or Ethernet network to remote DAS or DCS monitoring system by using Modbus/RTU or Modbus/TCP protocol.The system has the dual redundant network and long-distance communication function, which can ensure the disturb rejection capability and reliability of the communication network.The new
generation remote data acquisition and moni-toring system based on the high-performance embedded ARM microprocessor has important application significance.STRUCTRUE DESIGN OF THE WHOLE SYSTEM
The whole structure chart of the remote data acquisition and monitoring system based on embedded ARM platform is shown in Figure 1.In the scheme of the system, the remote I/O data acquisition modules are developed by embedded ARM processor, which can be widely used to diversified industries such as electric power, petroleum, chemical, metallurgy, steel, transportation and so on.This system is mainly used for the concentrative acquisition and digital conversion of a variety of electrical and thermal signals such as voltage, current, thermal resistance, thermo-couple in the production process.Then the converted data can be displayed on the LCD directly, and also can be sent to the embedded controller through RS485 or Ethernet network communication interface by using Modbus/RTU or Modbus/TCP protocol.The data in the embedded controller platform is transmitted to the work-stations of remote monitoring center by Ethernet after further analyzed and pro-cessed.At the same time, these data can be stored in the real time database of the database server in remote monitoring center.The system has the dual redun-dant network and long-distance communication
function, which can ensure the disturb rejection capability and reliability of the communication network.The hardware platform of the Remote I/O data acquisition system based on emb-edded ARM uses 32-bit ARM embedded microprocessor, and the software plat-form uses the real-time multi-task operating system uC/OS-II, which is open-source and can be grafted, cut out and solidified.The real time operating system(RTOS makes the design and expansion of the application becomes very easy, and without more changes when add new functions.Through the division of the appli-cation into several independent tasks, RTOS makes the design process of the application greatly simple.Figure 1 Structure of the whole system THE HARDWARE DESIGN OF THE SYSTEM
The remote I/O data acquisition system based on embedded ARM platform has high universality, each acquisition device equipped with 24-way acquisition I/O channels and isolated from each other.Each I/O channel can select a variety of voltage and current signals, as well as temperature signals such as thermal resis-tance, thermocouple and so on.The voltage signals in the range of 0-75 mV ,1-5V ,0-5V, and so on, the current signals in the range of 0-10mA and 4-20 mA, the thermal resistance measurement components including Cu50, Cu100, Pt50, Pt100, and the thermocouple measurement components including K, E, S, T, and so on.Figure2.Structure of the remote I/O data acquisition system based on ARM processor The structural design of the embedded remote I/O data acquisition system is shown in Figure 2.The system equipped with some peripherals such as power, keyboard, reset, LCD display, ADC, RS485, Ethernet, JTAG, I2C, E2PROM, and so on.The A/D interface circuit is independent with the embedded system, which is independent with the embedded system, which is system has setting buttons and 128*64 LCD, which makes the debugging and modification of the parameters easy.The collected data can be sent to the remote embedded controller or DAS, DCS system by using
Modbus/RTU or Modbus/TCP protocol through RS485 or Eth-ernet communication interface also, and then be used
for monitoring and control after farther disposal.The system of RS485 has a dual redundant network and long-distance communication function.As the embedded Ethernet interface makes the remote data exchange of the applications become very easy, the system can choose RS485 or Ethernet interface through jumper to communicate with host computer.Ethernet interface use independent ZNE-100TL intelligent embedded Ethernet to serial port conversion module in order to facilitate the system maintenance and upgrade.The ZNE-100TL module has an adaptive 10/100M Ethernet interface, which has a lot of working modes such as TCP Server, TCP Client, UDP, Real COM, and so on, and it can support four connections at most.Figure3.Diagram of the signal pretreatment circuit
Figure 3 shows the signal pretreatment circuit diagram.The signals of thermo-couple such as K,E,S,T etc and 0-500mV voltage signal can connect to the positive end INPx and the negative end INNx of the simulate multiplexers(MUX directly.The 4-20mA current signal and 1-5V voltage signal must be transformed by resis-tance before connecting to the positive end INPx and the negative end INNx of the MUX of certain channel.The RTD thermal resistance signals such as Cu50, Cu100, Pt50 and Pt100 should connect one 1mA constant current before connecting to the positive end INPx and the negative end INNx of the MUX of certain channel.Figure4.Diagram of ADC signal circuit Figure 4 shows the ADC signal circuit, which using the 16-bit ADC chip AD7715.The connection of the chip and the system is simple and only need
five lines which are CS(chip select, SCLK(system clock, DIN(data input, DOUT(data output and DRDY(data ready.As the ARM microprocessor has the characteristics of high speed, low power, low voltage and so on, which make its capacity of low-noise, the ripple of power, the transient response performance, the stability of clock source, the reliability of power control and many other aspects should be have higher request.The system reset circuit use special microprocessor power monitoring chip of MAX708S, in order to improve the reliability of the system.The system reset circuit is shown in Figure 5.Figure5.Diagram of system reset circuit
SOFTWARE DESIGN AND REALIZATION OF THE SYSTEM
The system software of the remote I/O data acquisition system based on embedded ARM platform use the real-time operating system(RTOS uC/OS-II, which is open-source and can be grafted,cut out and solidified.The key part of RTOS is the real-time multi-task core, whose basic functions including task management, resource management, system management, timer management, memory management, information management, queue management and so on.These functions are used though API service functions of the core.The system software platform use uC/OS-II real-time operating system core simplified the design of application system and made the whole structure of the system simple and the complex application hierarchical.The design of the whole system includes the tasks of the operating system and a series of user applications.The main function of the system is mainly to realize the initialization of the system hardware and the operating system.The initialization of hardware includes interr-upt、keyboard、LCD and so on.The initialization of operating system includes the control blocks and events control blocks, and before the start of multi-task schedu-ling, one task must be started at least.A start task has been created in this system, which is mainly responsible for the initialization and startup of clock, the start-up of interruption, the initialization of communication task module, as
well as the division of tasks and so on.The tasks must be divided in order to complete various functions of the real-time multi-task system.Figure6.Functional tasks of the system software Figure6 shows the functional tasks of the system software.According to importance of the tasks and the demands of real-time, the system applications are divided into six tasks with different priority, which including the tasks of A/D data acquisition, system monitoring, receive queue, data send, keyboard input, LCD display.The A/D data acquisition task demands the highest real-time requirements and the LCD display task is the lowest.Because each task has a different priority, the higher-priority task can access the ready one by calling the system hang up function or delay function.Figure7.Chart of AD7715 data transfer flow Figure 7 shows the data conversion flow of AD7715.The application A/D conversion is an important part of the data acquisition system.In the uC/OS-II real-time operating system core, the realization process of A/D driver depends mainly on the conversion time of A/D converter, the analog frequency of the conversion value, the number of input channels, the conversion frequency and so on.The typical A/D
conversion circuit is made up of analog multiplexer(MUX, amplifier and analog to digital converter(ADC.Figure8.Diagram of the application transfer driver Figure8 shows the application procedure transfer driver.The driver chooses the analog channel to read by MUX, then delay a few microseconds in order to make the signal pass through the MUX, and stabilize it.Then the ADC was triggered to start the conversion and the driver in the circle waiting for the ADC until its completion of the conversion.When waiting is in progress, the driver is detecting the ADC state signal.If the waiting time is longer than the set time, the cycle should be end.During waiting time of the cycle, if the conversion completed signal by ADC has been detected, the driver should read the results of the conversion and then return the result to the application.Figure9.Diagram of serial receive Figure9 shows the serial receive diagram with the buffer and signal quantity.Due to the existence of serial peripheral equipment does not match the speed of CPU, a buffer zone is needed, and when the data is sending to the serial, it need to be written to the buffer, and then be sent out through serial one by one.When the data is received from the serial port, it will not be processed until several bytes have been received, so the advance data can be stored in buffer.In practice, two buffer zones, the receiving buffer and the sending buffer, are needed to be opened from the memory.Here the buffer zone is defined as loop queue data structure.As the signal of uC/OS-II provides the overtime waiting mechanism, the serial also have the overtime reading and writing ability.If the initialization of the received data signal is 0, it expresses the loop buffer is empty.After the interrupt received, ISR read the received bytes from the UART receiving buffer, and put into receiving buffer region, at last wake the user task to execute read operation with the help of received signal.During the entire
process, the variable value of the current bytes in recording buffer can be inquired, which is able to shows whether the receive buffer is full.The size of the buffer zone should be set reasonable to reduce the possibility of data loss, and to avoid the waste of storage space.CONCLUSIONS
With the rapid development of the field of industrial process control and the wide range of applications of network, intelligence, digital distributed control System, it is necessary to make a higher demand of the data accuracy and reliability of the control system.Data acquisition system based on single-chip has been gradually eliminated because the problem of the poor real-time and reliability.With the fast popularization of embedded ARM processor, there has been a trend that ARM processor can alternate to single-chip to realize data acquisition and control.The embedded ARM system can adapt to the strict requirements of the data acquisition system, such as the function, reliability, cost, size, power consum-ption, and so on.In this paper, A kind of ARM-based embedded remote I/O data acquisition system has been researched and developed, whose hardware platform use 32-bit embedded ARM processor, and software platform use open-source RTOS uC/OS-II core.The system can be widely applied to electric power, petroleum, chemical, metallurgy, steel, transportation and so on.And it is mainly used in the collection and monitoring of all
kinds of electrical and thermal signals such as voltage, current, thermal resistance, thermocouple data of the production process.Then these data can be sent to the remote DAS, DCS monitoring system through RS485 or Ethernet interface.The system has the dual redundant network and long-distance communication function, which can ensure the disturb rejection capability and reliability of the communication network.基于嵌入式ARM平臺的遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)的研究和開發(fā)
導(dǎo)言
隨著網(wǎng)絡(luò)化,智能化,數(shù)字化分布式控制系統(tǒng)的廣泛使用,基于單芯片的數(shù)據(jù)采集系統(tǒng)不僅在處理能力上受限制,并且在實時性和可靠性方面也出現(xiàn)了問題。近幾年來,隨著工業(yè)過程控制領(lǐng)域的迅速發(fā)展和嵌入式ARM處理器的迅速普及,ARM處理器代替單芯片實現(xiàn)數(shù)據(jù)的采集和控制成為了趨勢。嵌入式ARM系統(tǒng)能適應(yīng)數(shù)據(jù)采集系統(tǒng)的嚴(yán)格要求,如功能性,可靠性,成本,體積,功耗等等。
在本文中提出一種新型的基于ARM嵌入式平臺的遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)已被研制開發(fā),它可以衡量各種電氣和熱參數(shù),如電壓,電流,熱電偶,熱電阻等等。那個測量數(shù)據(jù)可以顯示在液晶顯示器的系統(tǒng)中,同時可通過使用Modbus / RTU或的Modbus / TCP協(xié)議從RS485或以太網(wǎng)網(wǎng)絡(luò)傳送到DAS或DCS遠(yuǎn)程監(jiān)控
系統(tǒng)。該系統(tǒng)具有雙冗余網(wǎng)絡(luò)和長途電通信功能,它可以確保通信網(wǎng)絡(luò)的干擾抑制能力和可靠性?;诟咝阅芮度胧紸RM微處理器的新一代遠(yuǎn)程數(shù)據(jù)采集和監(jiān)控系統(tǒng)具有重要的應(yīng)用意義。
整個系統(tǒng)的結(jié)構(gòu)設(shè)計
基于嵌入式ARM的平臺的遠(yuǎn)程數(shù)據(jù)采集和監(jiān)控系統(tǒng)的整個結(jié)構(gòu)圖在以下的圖1中展示。在這系統(tǒng)的計劃中,通過使用廣泛用于多種行業(yè)如電氣電力,石油,化工,冶金,鋼鐵,運輸?shù)鹊那度胧紸RM處理器來開發(fā)遠(yuǎn)程I / O數(shù)據(jù)采集模塊。該系統(tǒng)主要用于的集中采購和將各種電和熱信號如電壓,熱電阻,熱電偶在生產(chǎn)過程中進(jìn)行數(shù)字轉(zhuǎn)換。轉(zhuǎn)換的數(shù)據(jù)可直接在液晶顯示器上顯示,也可以通過使用的Modbus / RTU或的Modbus / TCP協(xié)議的RS485總線或以太網(wǎng)網(wǎng)絡(luò)通信接口被發(fā)送到嵌入式控制器。嵌入控制器平臺的數(shù)據(jù)通過進(jìn)一步以太網(wǎng)的分析和處理被傳送至遠(yuǎn)程監(jiān)控中心的工作站。與此同時,這些數(shù)據(jù)可以存儲在遠(yuǎn)程監(jiān)控中心數(shù)據(jù)庫服務(wù)器的實時數(shù)據(jù)庫中。該系統(tǒng)具有雙冗余網(wǎng)絡(luò)和遠(yuǎn)程通訊功能,它可以確保通信網(wǎng)絡(luò)的干擾抑制能力和可靠性。
基于嵌入式ARM遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)的硬件平臺使用32位ARM嵌入式微處理器和軟件平臺使用的是開源的并且可移植,削減和鞏固的實時多任務(wù)操作系統(tǒng)的第二代UC / OS核心。實時操作系統(tǒng)(RTOS)使設(shè)計和應(yīng)用的擴大變得非常容
易,增加新的功能時也沒多大變化。通過幾個獨立的任務(wù)的應(yīng)用,實時操作系統(tǒng)使得應(yīng)用的設(shè)計過程極為簡單。
系統(tǒng)的硬件設(shè)計
基于嵌入式ARM平臺的遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)具有很高的普遍性,每個購置設(shè)備配備24收購方式的I / O渠道且彼此孤立。每個I / O通道可以選擇不同的電壓和電流信號,以及溫度信號如熱電阻,熱電偶等。在05V的,010毫安和4100TL智能嵌入式以太網(wǎng)串口轉(zhuǎn)換模塊。該ZNE500mV的電壓信號可以直接接到模擬多路復(fù)用器(復(fù)用器)的INPx正極和INNx負(fù)極。45V的電壓信號必須用阻抗轉(zhuǎn)換。熱電阻的電阻信號如Cu50,Cu100,Pt50和Pt100應(yīng)在接到某些頻道的復(fù)用器INPx正極和INNx負(fù)極前連接一1毫安的恒流源。
圖4顯示了使用16位ADC芯片AD7715的ADC信號電路。芯片與系統(tǒng)的連接非常簡單,只需要CS(芯片選擇),SLCK(系統(tǒng)時鐘),DIN(數(shù)據(jù)輸入),DOUT(數(shù)據(jù)輸出)和DRDY(數(shù)據(jù)準(zhǔn)備)5根線。
由于ARM微處理器具有高速,低功耗,低電壓等優(yōu)點,這使它在低噪音,紋波權(quán)力,瞬態(tài)響應(yīng)性能,時鐘來源的穩(wěn)定,功率控制和許多其他方面需要有更高的要求。為了改善系統(tǒng)的可靠性該系統(tǒng)復(fù)位電路中使用特殊的微處理器電源監(jiān)測芯片MAX708S。圖5展示了該系統(tǒng)復(fù)位電路。
系統(tǒng)軟件的設(shè)計與實現(xiàn)
基于嵌入式ARM平臺的遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)的軟件使用的是開源的并且可移植,削減和鞏固的實時多任務(wù)操作系統(tǒng)的第二代UC / OS核心。RTOS的關(guān)鍵部分是實時多任務(wù)的核心,其基本功能包括任務(wù)管理,資源管理,系統(tǒng)管理,計時器管理,內(nèi)存管理,信息管理,隊列管理等。通過API服務(wù)職能核心使用這些功能。
該系統(tǒng)軟件平臺使用的是單一化的uC/ OS第二代實時簡化操作系統(tǒng)核心,使整個結(jié)構(gòu)系統(tǒng)簡單和應(yīng)用層次復(fù)雜。整個系統(tǒng)的設(shè)計包括操作系統(tǒng)的任務(wù)和一系列的用戶應(yīng)用程序。系統(tǒng)的主要職能是實現(xiàn)系統(tǒng)硬件和操作系統(tǒng)的初始化。硬件初始化包括中斷,鍵盤,液晶顯示器等。操作系統(tǒng)初始化包括控制模塊和事件控制,在多任務(wù)調(diào)度前,至少有一個任務(wù)開始。一個開端任務(wù)已建立在這一系統(tǒng),這系統(tǒng)主要負(fù)責(zé)初始化和啟動的時鐘,開辦中斷,通信任務(wù)模塊的初始化,以及任務(wù)分工等。為了完成實時多任務(wù)系統(tǒng)的多種職能那個任務(wù)必須被劃分。
圖6顯示系統(tǒng)軟件的功能任務(wù)。根據(jù)任務(wù)的重要性和實時要求,系統(tǒng)的應(yīng)用曾劃分為六個不同優(yōu)先級的任務(wù),其中包括A / D數(shù)據(jù)采集任務(wù),系統(tǒng)監(jiān)控,接受隊列,數(shù)據(jù)傳送,鍵盤輸入,液晶顯示屏顯示。A / D數(shù)據(jù)采集任務(wù)要求最高的實時要求和液晶顯示器顯示任務(wù)是最低的。因為每個任務(wù)都有不同的優(yōu)先事項,通過使用系統(tǒng)掛斷功能或延遲功能更高的優(yōu)先任務(wù)可以開始已經(jīng)準(zhǔn)備好的任務(wù)。
圖7顯示的是AD7715的數(shù)據(jù)轉(zhuǎn)換流。A / D轉(zhuǎn)換器的應(yīng)用是數(shù)據(jù)采集系統(tǒng)的一個重要組成部分。在uS/ OS的第二代實時操作系統(tǒng)的核心中,A / D驅(qū)動程序的實現(xiàn)過程主要取決于A / D轉(zhuǎn)換器的轉(zhuǎn)換時間,有轉(zhuǎn)換價值的模擬頻率,輸入通
道的數(shù)量,轉(zhuǎn)換頻率等等。典型的A / D轉(zhuǎn)換電路由模擬復(fù)用器(復(fù)用器),放大器和模擬到數(shù)字轉(zhuǎn)換器(ADC)組成。
圖8顯示了申請程序轉(zhuǎn)移的驅(qū)動程序。驅(qū)動程序可以在模擬通道讀取由復(fù)用器,那么幾微秒的延遲,以便使信號通過多路開關(guān),并使其穩(wěn)定。然后,當(dāng)轉(zhuǎn)換開始時,ADC被觸發(fā),并且驅(qū)動程序在一個周期內(nèi)等待ADC的觸發(fā),直到完成轉(zhuǎn)換。當(dāng)?shù)却倪M(jìn)展,該驅(qū)動程序檢測ADC的狀態(tài)信號。如果等待時間比規(guī)定的時間越長,周期應(yīng)該結(jié)束。在等待的周期時間,如果轉(zhuǎn)換完成ADC的信號被檢測到,驅(qū)動程序應(yīng)改為轉(zhuǎn)換的結(jié)果,然后將結(jié)果返回給應(yīng)用程序。
圖9顯示了緩沖區(qū)和信號量的序列接收圖。由于外圍串行設(shè)備的存在CPU的運行速度匹配,一個緩沖區(qū)是必要的,當(dāng)數(shù)據(jù)發(fā)送到序列,它必須被寫入緩沖區(qū),然后通過串行逐一地被發(fā)送出去。當(dāng)從串行端口收到數(shù)據(jù),這些數(shù)據(jù)將不會被處理直到收到一些字節(jié),因此先前的數(shù)據(jù)可以存儲在緩沖區(qū)中。在實踐中,兩個緩沖區(qū),一個接收緩沖區(qū)和一個發(fā)送緩沖區(qū),它們是需要從內(nèi)存開放出來。在這里緩沖區(qū)像循環(huán)隊列數(shù)據(jù)結(jié)構(gòu)一樣被定義。
由于uC/OS-II提供額外時間等待機制的信號,串口也具有額外的閱讀和寫作能力。如果收到的數(shù)據(jù)信號初值為0,它表示循環(huán)緩沖區(qū)是空的。在中斷收到后,ISR從UART接受緩沖區(qū)中讀到收到的數(shù)據(jù),并投入接收緩沖區(qū)域,最后通過收到的數(shù)據(jù)開始用戶執(zhí)行讀操作的的任務(wù)。在整個過程中,變量價值目前字節(jié)在存儲緩沖區(qū)中的字節(jié)的變量值是可以被詢問的,這能夠表明接收緩沖區(qū)是否已滿。為了降低數(shù)據(jù)丟失的可能性和避免浪費存儲空間應(yīng)合理地設(shè)置緩沖區(qū)的大小。
結(jié)論
隨著工業(yè)過程控制領(lǐng)域的快速發(fā)展和網(wǎng)絡(luò),智能,數(shù)字化分布式控制系統(tǒng)廣泛應(yīng)用,有必要發(fā)展對數(shù)據(jù)準(zhǔn)確性和控制可靠性要求更高的系統(tǒng)。由于較差的實時性和可靠性基于單片機數(shù)據(jù)采集系統(tǒng)已逐步被淘汰。隨著嵌入式ARM處理器的迅速普及,ARM處理器替代單芯片實現(xiàn)數(shù)據(jù)采集與控制成為了一種新的趨勢。嵌入式ARM系統(tǒng)能夠適應(yīng)數(shù)據(jù)采集系統(tǒng)的嚴(yán)格要求,如功能,可靠性,成本,大小,耗電量等等。
在本文中一種基于ARM的嵌入式遠(yuǎn)程I / O數(shù)據(jù)采集系統(tǒng)已被研究和開發(fā),其硬件平臺采用32位嵌入式ARM處理器和軟件平臺的使用開源的RTOS uS/ OS-Ⅱ核心。該系統(tǒng)可廣泛應(yīng)用于電力,石油,化工,冶金,鋼鐵,交通運輸?shù)确矫?。這是主要用于收集和監(jiān)測各種電氣和熱信號,如電壓,電流,熱電阻,生產(chǎn)過程中的熱電偶數(shù)據(jù)。然后通過RS485或以太網(wǎng)接口將這些數(shù)據(jù)發(fā)送到遠(yuǎn)程的DAS,DCS控制系統(tǒng)的監(jiān)測系統(tǒng)。該系統(tǒng)具有雙冗余網(wǎng)絡(luò)和長途通信功能,它可以確保干擾抑制和通信網(wǎng)絡(luò)的可靠性。
第五篇:采用服務(wù)器端嵌入式腳本語言PHP3進(jìn)行Linux下的網(wǎng)站開發(fā)
中國搜課網(wǎng) http://004km.cn
課件 教案 試題 論文 圖書 中考 高考 新課標(biāo)
采用服務(wù)器端嵌入式腳本語言PHP3進(jìn)行Linux下的網(wǎng)站開發(fā) ux下安裝,不過如果用于商業(yè)用途需要付費.PostgreSQL也是Linux下的免費數(shù)據(jù)庫,RedHat5里面就帶了,不過我沒有用過,就不說了.mSQL與MySQL既然本來就是差不多的兩個東西,PHP中對它們的訪問語句也都差不多,例如msql_close與mysql_close就分別完成同樣的關(guān)閉動作.所以以下介紹時只對mysql介紹,msql的訪問語句只需換個前綴即可(特殊情況另行說明).注意:mSQL與MySQL訪問函數(shù)都需要有相應(yīng)的權(quán)限才能運行.(1)mysql_connect(主機,用戶名,口令);返回一個連接號.注意:mysql各用戶的口令可以隨該用戶所在機器IP地址不同而改變.另外,mSQL沒有用戶名機制,所以msql_connect只需要一個主機參數(shù).主機可以是IP地址或域名.(2)mysql_create_db(數(shù)據(jù)庫名);(3)mysql_select_db(數(shù)據(jù)庫名,連接號);連接一個數(shù)據(jù)庫.(4)mysql_query(SQL語句,連接號);如果SQL語句是select,則返回一個結(jié)果號.否則返回的值可以不理會.如果失敗,返回false.(5)mysql_fetch_array(結(jié)果號);取出下一行,返回一個數(shù)組.可以用數(shù)字下標(biāo)訪問(第一個字段是下標(biāo) 0),《采用服務(wù)器端嵌入式腳本語言PHP3進(jìn)行Linux下的網(wǎng)站開發(fā)》一文由中國搜課網(wǎng)搜集整理,版權(quán)歸作者所有,轉(zhuǎn)載請注明出處!
中國搜課網(wǎng) http://004km.cn 提供中小學(xué)全科課件、教案、論文、中高考試題、新課標(biāo)資源、電子圖書搜索與下載服務(wù)。