• <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>
            Impossible is nothing  
              愛過知情重醉過知酒濃   花開花謝終是空   緣份不停留像春風來又走   女人如花花似夢
            公告
            日歷
            <2006年10月>
            24252627282930
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234
            統計
            • 隨筆 - 8
            • 文章 - 91
            • 評論 - 16
            • 引用 - 0

            導航

            常用鏈接

            留言簿(4)

            隨筆分類(4)

            隨筆檔案(8)

            文章分類(77)

            文章檔案(91)

            相冊

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

             
              /* The following macros process structure members:  to determine the       */
              /* offset of a structure member from the beginning of the structure, and   */
              /* to detemine the size of a member of a structure.                        */

              #define DEFS_OFFSET(s,m)       (DEFS_UI16)&(((s *)0)->m)
              #define DEFS_MEMBER_SIZE(s,m)  sizeof(((s *)0)->m)

              /* The following macros make it easier to specify binary numbers. For      */
              /* example, to specify a byte in binary:  DEFS_BINARY(01100001) or to   */
              /* specify a word in binary:  DEFS_BINARY_WORD(00111101,11001010)       */

              #define DEFS_BINARY_CONVERT(byte) (((byte & 0x10000000L) / 0x200000L) +  \
                                                    ((byte & 0x01000000L) / 0x040000L) +  \
                                                    ((byte & 0x00100000L) / 0x008000L) +  \
                                                    ((byte & 0x00010000L) / 0x001000L) +  \
                                                    ((byte & 0x00001000L) / 0x000200L) +  \
                                                    ((byte & 0x00000100L) / 0x000040L) +  \
                                                    ((byte & 0x00000010L) / 0x000008L) +  \
                                                    ((byte & 0x00000001L) / 0x000001L))

              #define DEFS_BINARY(byte) DEFS_BINARY_CONVERT(0x##byte)

              #define DEFS_BINARY_WORD(high,low) (DEFS_BINARY_CONVERT(0x##high) * 256) + \

            2006.1.7 字節交換順序

            /* This is a set of routines for demonstrating the effects of
             byte ordering between little endian and big endian machines

             Big Endian (B_ENDIAN == TRUE):

              MSB [ n | n+1 | n+2 | n+3 ] LSB

             Little Endian (B_ENDIAN == FALSE):

              MSB [ n+3 | n+2 | n+1 | n] LSB

             little/big-endian is bitness as well.  For example,

              struct {
               short b:5,   --- we _want_ signed for the example ---
               c:11;
              };

             is stored in little-endian (gint32el) ['+' denotes sign bit]:

             tf_Bitstream view -->
               0123456789A BCDEF
              |-----c----+|--b-+|

             Whereas bigendian (Motorola) stores it thus:

             tf_Bitstream view -->
               FEDCB A9876543210
              |+-b--|+----c-----|

             So, you have to invert bits as well to convert endianness.

             #define Gettf_Bit(Val,Idx) ( ( (Val) & (1<<(Idx)) ) )
             #define Settf_Bit(Val,Idx,tf_Bit) ( ( (Val) & (~(1<<Idx)) ) | ((tf_Bit)<<(Idx)) )
             for ( i = 0; i < sizeof(Val)*8; i++)
                NewVal = Settf_Bit(NewVal,sizeof(Val)*8-i-1, Gettf_Bit(Val,i));
            */        

            DNP
            DnpMasterStart
              --> taskSpawn ("tDnpMaster", priority, VX_FP_TASK, 0x8000,
                    (FUNCPTR) DnpMasterTask,
                    (int) ini_name, 0, 0, 0, 0, 0, 0, 0, 0, 0)
                   
               dnpMasterTask ---> dnp_init()
                             ---> ca_task_initialize()
                             ---> ca_add_fd_registration()
                             ---> 從配置文件中得到dnp的配置信息
                             ---> pdpdvrs_initDNP()
                             ---> addr_init()
                             ---> dnp_loop()
                   
              DnpMasterAddDevice
              DnpMasterAdd8550
              DnpMasterAddText
             
              DNP PEER TO PEER
             
              一些debug信息
             
              物理層
               .利用查表法來確定鏈路層的長度
              --->. pdpphys_initPhysRecMgr 物理層初始化,分配內存
                 . valid_address()
                . pdpphys_parseDNPframe() 
             
             
              DnpMasterTask
              

            ========================================================

              串口:從溫舊夢

               非重疊模式優點 .直接
                       .易移植
                    缺點 .線程中讀、寫相互堵塞
                       .線程間相互堵塞(包括讀之間,寫之間,讀寫之間)
             
                    單片機,嵌入式如vxworks,任務中相對簡單的程序中常用
             
               重疊模式 優點 .靈活,效率高(后臺執行操作)
                       .多線程間,線程中,讀寫操作不會相互堵塞
                    缺點 .不那么直接
                       .不易于移植
               
              EV_RXCHAR:事件通知模式用在非重疊模是一個比較好的方式,因為程序不用輪詢串口,以節省CPU的thread quantum
                    方式如下:
                   DWORD dwCommEvent;
               DWORD dwRead;
               char  chRead;
               
               if (!SetCommMask(hComm, EV_RXCHAR))
                  // Error setting communications event mask.
               
               for ( ; ; ) {
                  if (WaitCommEvent(hComm, &dwCommEvent, NULL)) {
                     if (ReadFile(hComm, &chRead, 1, &dwRead, NULL))
                        // A byte has been read; process it.
                     else
                        // An error occurred in the ReadFile call.
                        break;
                  }
                  else
                     // Error in WaitCommEvent.
                     break;
               }
               問題出現在:當多個字節連續的發送,第1個byte到,引起EV_RXCHAR 事件發生,
                                      WaitCommEvent指示可讀.第2個byte緊接著到,EV_RXCHAR只是在內部置位,
                                      當第1個byte讀完,調用WaitCommEvent時,系統再次指示EV_RXCHAR 事件發生,
                                      可讀第2個byte,問題出現在當第2個字符到達,而沒有被讀出時,第3個字符到
                                      達了,此時系統也期望將對應于第3個字符的EV_RXCHAR置位,但是系統中的
                                      EV_RXCHAR標志位已經被第2個已經置位了,于是就被忽略,當第2個自負讀出
                    后,只能在系統緩沖區,等待第4個字符到,而讀出第3個字符,這樣代碼和系統
                                      就失去同步。
                     (我覺得這種情況在一般情況下不會出現,在單片機、
                                           嵌入式應該是一個一個字符往外蹦,)
               
                     而且WaitCommEvent會導致很多其它事件丟失,在高速情況下。
                      
                解決辦法是:利用ClearCommError判斷緩沖中的字符個數,一次性讀完所有到達字符

            posted on 2006-03-03 15:23 笑笑生 閱讀(757) 評論(1)  編輯 收藏 引用 所屬分類: C++語言
            評論:
            • # re: C經典用法  py Posted @ 2006-10-28 18:46
              沒有發現可以看清楚的代碼哈。。。555  回復  更多評論   

             
            Copyright © 笑笑生 Powered by: 博客園 模板提供:滬江博客
            婷婷久久久亚洲欧洲日产国码AV| 久久精品国产亚洲一区二区| 看全色黄大色大片免费久久久| 久久亚洲国产成人影院网站| 久久精品国产久精国产果冻传媒 | 精品多毛少妇人妻AV免费久久| 久久国产美女免费观看精品 | 久久久久久国产精品无码下载| 中文字幕乱码久久午夜| 久久婷婷综合中文字幕| 欧美精品九九99久久在观看| 久久久久久无码Av成人影院 | 亚洲中文字幕无码久久2017| 久久精品国产99国产电影网| 久久伊人五月丁香狠狠色| 久久se精品一区二区影院 | 久久青草国产手机看片福利盒子| 久久精品二区| 久久久久久久尹人综合网亚洲 | 久久精品国产亚洲网站| 国产A级毛片久久久精品毛片| 天天综合久久久网| 99久久99久久久精品齐齐| 蜜桃麻豆WWW久久囤产精品| 国产精品成人99久久久久| 久久久久亚洲AV无码麻豆| 性欧美大战久久久久久久久| 九九精品久久久久久噜噜| 久久久久亚洲爆乳少妇无| 国产精品久久久久一区二区三区| 国产精品久久久久aaaa| 国产日产久久高清欧美一区| 国产精品久久久久久影院| 亚洲中文久久精品无码ww16| 欧美精品国产综合久久| 2020国产成人久久精品| 婷婷久久五月天| 色欲综合久久中文字幕网| 国产亚洲精品久久久久秋霞| 亚洲精品tv久久久久久久久 | 99久久婷婷国产综合精品草原 |