• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            2010年8月8日

            SVN客戶端腳本(LUA)

             1 --打開日志文件
             2 svnlogPath = assert(arg[3], "路徑為空");
             3 svnlog = assert(io.open(svnlogPath, "r"), "打開日志文件失敗!");
             4 
             5 --日志是否為空
             6 if svnlog:read(0== nil then
             7     --日志為空
             8     svnlog:close();
             9     io.stderr:write("請(qǐng)?zhí)顚懭罩荆?/span>");
            10     os.exit(1);
            11 else
            12     --檢查日志內(nèi)容
            13     local count = 1;
            14     while true do
            15         local line = svnlog:read();
            16 
            17         if line == nil then
            18             break;
            19         end
            20 
            21         --查找是否匹配
            22         if string.len(line) > 0 then
            23             if not string.find(line, ".:%s*%S") then
            24                if not string.find(line, ".\239\188\154%s*%S") then
            25                  svnlog:close();
            26                  io.stderr:write("日志沒有填寫完整");
            27                  os.exit(1);
            28                 end
            29             end
            30         end
            31 
            32         count = count + 1;
            33     end
            34 
            35     --檢查行數(shù)是否>6行
            36     if count < 6 then
            37          svnlog:close();
            38          io.stderr:write("請(qǐng)?zhí)顚懲暾罩? ");
            39          os.exit(1);
            40     end
            41 
            42 end
            43 
            44 svnlog:close();
            45 

            posted @ 2010-08-08 21:22 gewala 閱讀(430) | 評(píng)論 (0)編輯 收藏

            2009年11月8日

            在EZ430開發(fā)板的串口類異常

              我發(fā)現(xiàn)串口類cnComm在串口轉(zhuǎn)USB的設(shè)備上有些能工作(USB430),但在EZ430上卻不能工作,很奇怪!我懷疑是硬件問題,畢竟串口轉(zhuǎn)USB硬件上有差別。我發(fā)現(xiàn)cnComm的線程一直收到一些不存在的事件,導(dǎo)致死循環(huán)。
              今天上網(wǎng)看了一篇資料,說(shuō)是那個(gè)DCB配置了硬件握手協(xié)議導(dǎo)致了一些不支持這個(gè)功能的串口轉(zhuǎn)USB設(shè)備出錯(cuò)。我覺得有點(diǎn)道理,有時(shí)間試驗(yàn)一下。先看一下cnComm的DCB配置情況。

            摘抄

                使用API進(jìn)行串口編程時(shí)設(shè)置串口屬性(SetCommState)是一條必經(jīng)之路,其DCB結(jié)構(gòu)幾乎涵蓋了所有和串口通訊相關(guān)的資源設(shè)置,由于有些設(shè)備需要使用RTS和CTS進(jìn)行數(shù)據(jù)的收發(fā)控制,為了提高接收效率可以使用RTS握手選項(xiàng)dcb.fRtsControl=RTS_CONTROL_HANDSHAKE; 在標(biāo)準(zhǔn)串口下使用一切正常,但在一些沒有標(biāo)準(zhǔn)串口的筆記本上卻不能發(fā)送數(shù)據(jù),后經(jīng)過(guò)仔細(xì)排查發(fā)現(xiàn)就是RTS握手選項(xiàng)搞的鬼,關(guān)閉此選項(xiàng)后一切恢復(fù)正常。

                由于公司只有一種USB轉(zhuǎn)RS232的設(shè)備,所以也沒有測(cè)試其他品牌/類型的設(shè)備是否也存在這個(gè)問題。如果有朋友遇到串口通訊在USB轉(zhuǎn)RS232下不好用的時(shí)候,可以看看RTS握手選項(xiàng)的狀態(tài)。


                發(fā)現(xiàn)cnComm打開了發(fā)送和接收的流控制,fDtrControl=DTR_CONTROL_ENABLE,fRtrControl=RTR_CONTROL_ENABLE。有可能是這個(gè)原因。

            posted @ 2009-11-08 00:00 gewala 閱讀(426) | 評(píng)論 (0)編輯 收藏

            2009年11月3日

            內(nèi)存溢出檢測(cè)學(xué)習(xí)

              最近發(fā)現(xiàn)CRT控制臺(tái)程序沒有TRACE和內(nèi)存溢出檢查,很郁悶。無(wú)聊中翻看MSDN的Memory Management and the Debug Heap篇,發(fā)現(xiàn)C的Debug版本用_malloc_dbg代替malloc,而_malloc_dbg者給數(shù)據(jù)堆加上一個(gè)控制頭組成鏈表,方便記錄溢出。原話如下:
              When you request a memory block, the debug heap manager allocates from the base heap a slightly larger block of memory than requested and returns a pointer to your portion of that block. For example, suppose your application contains the call: malloc( 10 ). In a release build, malloc would call the base heap allocation routine requesting an allocation of 10 bytes. In a debug build, however, malloc would call _malloc_dbg, which would then call the base heap allocation routine requesting an allocation of 10 bytes plus approximately 36 bytes of additional memory. All the resulting memory blocks in the debug heap are connected in a single linked list, ordered according to when they were allocated:
              那個(gè)控制頭的數(shù)據(jù)結(jié)構(gòu)如下:
            typedef struct _CrtMemBlockHeader
            {
            // Pointer to the block allocated just before this one:
               struct _CrtMemBlockHeader *pBlockHeaderNext; 
            // Pointer to the block allocated just after this one:
               struct _CrtMemBlockHeader *pBlockHeaderPrev; 
               
            char *szFileName;   // File name
               int nLine;          // Line number
               size_t nDataSize;   // Size of user block
               int nBlockUse;      // Type of block
               long lRequest;      // Allocation number
            // Buffer just before (lower than) the user's memory:
               unsigned char gap[nNoMansLandSize];  
            } _CrtMemBlockHeader;

              這個(gè)nBlockUse有6種內(nèi)存塊,具體含義還沒有搞清楚,分別如下
            /* Memory block identification */
            #define _FREE_BLOCK      0
            #define _NORMAL_BLOCK    1
            #define _CRT_BLOCK       2
            #define _IGNORE_BLOCK    3
            #define _CLIENT_BLOCK    4
            #define _MAX_BLOCKS      5
              檢測(cè)內(nèi)存溢出用_CrtDumpMemoryLeaks(),在crtdbg.h中定義。有時(shí)間研究一下crtdbg.h文件。
              參考http://www.cnblogs.com/phinecos/archive/2009/10/29/1592604.html


            posted @ 2009-11-03 22:53 gewala 閱讀(1067) | 評(píng)論 (0)編輯 收藏

            2009年10月21日

            一個(gè)時(shí)間軟件

              從NIST網(wǎng)站上下了個(gè)時(shí)間軟件,看起來(lái)很古老,但功能強(qiáng)大。我在NIST網(wǎng)站上一直找不到網(wǎng)絡(luò)時(shí)間服務(wù)器,但在這個(gè)軟件中發(fā)現(xiàn)可以下載更新服務(wù)器地址,很好很強(qiáng)大。
            下載
             

            posted @ 2009-10-21 22:18 gewala 閱讀(250) | 評(píng)論 (0)編輯 收藏

            2009年10月20日

            一些API函數(shù)--《windows程序設(shè)計(jì)》

               《window程序設(shè)計(jì)》果然是經(jīng)典,相對(duì)于MFC來(lái)說(shuō)SDK簡(jiǎn)直是返璞歸真啊。繼續(xù)摘錄一些API函數(shù)和技巧:
              CheckRadioButton(hwnd,IDC_SERVER1,IDC_SERVER10, wServer);
              1、Selects (adds a check mark to) a given radio button in a group and clears (removes a check mark from) all other radio buttons in the group. 在IDC_SERVER1-IDC_SERVER10中選中wServer的ID,有點(diǎn)像分組。

              DialogBoxParam (hInst, TEXT ("Servers"), hwnd, ServerDlg, (LPARAM) szIPAddr);
              2、可以在WM_INITDIALOG的LPARAM傳參數(shù),建立模態(tài)對(duì)話框。ServerDlg為消息處理函數(shù),szIPAddr為參數(shù),在WM_INITDIALOG消息響應(yīng)中處理LPARAM的值。

            typedef char *  va_list;

            #define _INTSIZEOF(n)   ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
            #define va_start(ap,v)  ( ap = (va_list)&v + _INTSIZEOF(v) )
            #define va_arg(ap,t)    ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
            #define va_end(ap)      ( ap = (va_list)0 )
              3、va_list可變參數(shù)的結(jié)構(gòu),有點(diǎn)復(fù)雜慢慢看。
              一般的用法是這樣(個(gè)人理解)
            va_list args; //聲明變量
            va_start(args, fmt); //開始解析。args指向fmt后面的參數(shù)
            TYPE var = va_arg(args, TYPE); //取下一個(gè)參數(shù)并返回。args指向下一個(gè)參數(shù)
            va_end(args); //結(jié)束解析
            http://hi.baidu.com/kang_liang/blog/item/168c9059a9a1ca2d2934f05f.html

              4、wsprintf和wvsprintf的區(qū)別,從它們的參數(shù)可以看出。
            int wsprintf(
              LPTSTR lpOut,    
            // output buffer
              LPCTSTR lpFmt,   // format-control string
                            // optional arguments
            );

            int wvsprintf( LPTSTR lpOutput, // buffer for output
                           LPCTSTR lpFormat, // format-control string
                           va_list
            // variable list of format-control arguments
                           );

              wsprintf純粹是格式化字符串,wvsprintf是以參數(shù)列表Va_list格式化字符串。

            posted @ 2009-10-20 22:36 gewala 閱讀(530) | 評(píng)論 (0)編輯 收藏

            2009年10月19日

            strtok用法--提取字符串

                最近看Petzold的《windows程序設(shè)計(jì)》,在Internet那章中看到如何在字符串中提取IP地址,特地標(biāo)記一下:
            1 GetDlgItemTextA (hwnd, wServer, szLabel, sizeof (szLabel));
            2 strtok (szLabel, "(");
            3 strcpy (szServer, strtok (NULL, ")"));
                在Msdn上查了一下,有下面一段:

                On the first call to strtok , the function skips leading delimiters and returns a pointer to the first token in strToken , terminating the token with a null character. More tokens can be broken out of the remainder of strToken by a series of calls to strtok . Each call to strtok modifies strToken by inserting a null character after the token returned by that call. To read the next token from strToken , call strtok with a NULL value for the strToken argument. The NULL strToken argument causes strtok to search for the next token in the modified strToken . The strDelimit argument can take any value from one call to the next so that the set of delimiters may vary.

            Warning    Each of these functions uses a static variable for parsing the string into tokens. If multiple or simultaneous calls are made to the same function, a high potential for data corruption and inaccurate results exists. Therefore, do not attempt to call the same function simultaneously for different strings and be aware of calling one of these function from within a loop where another routine may be called that uses the same function.  However, calling this function simultaneously from multiple threads does not have undesirable effects.

                看來(lái)用了靜態(tài)變量,還好有多線程的C運(yùn)行庫(kù),否則在多線程在有麻煩了。

            posted @ 2009-10-19 23:05 gewala 閱讀(2343) | 評(píng)論 (0)編輯 收藏

            僅列出標(biāo)題  
            <2025年6月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            設(shè)計(jì)模式 網(wǎng)絡(luò)編程

            網(wǎng)絡(luò)

            搜索

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久精品水蜜桃av综合天堂| 欧美麻豆久久久久久中文| 久久久久亚洲精品男人的天堂| 国产成人精品久久一区二区三区av| 久久精品亚洲男人的天堂| 久久精品国产精品亚洲精品| 久久久久人妻一区精品色| 久久成人影院精品777| 伊色综合久久之综合久久| 久久精品成人欧美大片| 国产精品99精品久久免费| 久久婷婷五月综合成人D啪| avtt天堂网久久精品| 久久久久亚洲av成人无码电影| 久久精品国产亚洲AV影院| 久久久久中文字幕| 四虎国产精品免费久久5151| 午夜精品久久久久| 久久国产精品波多野结衣AV | 亚洲国产二区三区久久| 日本强好片久久久久久AAA| 日本精品久久久久久久久免费| 久久精品国产亚洲av水果派| 无码人妻久久一区二区三区蜜桃 | 亚洲国产综合久久天堂| 久久久网中文字幕| 好久久免费视频高清| 麻豆一区二区99久久久久| 欧美大战日韩91综合一区婷婷久久青草 | 久久久久久曰本AV免费免费| 精品无码久久久久久国产| 久久精品国产影库免费看| 91精品国产9l久久久久| 99久久精品毛片免费播放| 亚洲精品无码久久久久| 久久国产精品成人影院| 一本久道久久综合狠狠爱| 国产精品一区二区久久| 久久Av无码精品人妻系列| 国产午夜免费高清久久影院 | 亚洲AV乱码久久精品蜜桃|