Transferred from: Author: Arm-WinCE (Microsoft MVP)
Whether in wince5.0 or wince6.0, we will use the print function when debugging the driver or application. In the driver, we may use debugmsg (...), retailmsg (...), and nkdbuplintfw (..). Before using these print functions to debug our program, we need to implement the serial port printing function.
In the BSP of wince, if you want to call debugmsg (..) or retailmsg (..) to print information from the serial port, we must find debug at the oal layer in our BSP. c. Implement the following four functions in this file:
Void oeminitdebugserial (void): Initialize the serial port used to print information
Int oemreaddebugbyte (void): Read a byte from the serial port. If an error occurs, oem_debug_com_error is returned. If no data exists, oem_debug_read_nodata is returned.
Void oemwritedebugbyte (byteCh): Write a byte to the serial port.
Void oemwritedebugstring (unsigned short * Str): Write a string to the serial port. This function is actually implemented by calling oemwritedebugbyte.
After the above four functions are implemented, You can debug the program through serial port printing. Generally, these four functions are implemented in debug. C of OAL.
In BSP, we usually use three functions to print: debugmsg, retailmsg, and nkdbuplintfw. A Brief Introduction:
The nkdbuplintfw (...) function is generally used only in oal and can print information directly from the serial port without being affected by the compilation option.
The debugmsg (...) function prints information only after the project is compiled in debug mode. If it is compiled in release mode, the information will not be printed.
==================================== Here I want to correct it
During driver development of wince, we usually compile the project into the release mode. If the compilation is in debug mode, the compilation result (NK) will be very large, exceeding the limit on NK in the code.
In addition, sometimes we only need to understand the debugging information of individual device drivers, and do not need to compile the entire project into the debug mode.
In this case, you can use this method to add the following to the driver file header:
# UNDEF debugmsg
# Define debugmsg (x, S) nkdbuplintfw s
In this way, all the debugging information in the driver file will be printed and the debugzone settings will be ignored.
======================================================-- Repost the independent yutai website, the verification is indeed feasible.
The retailmsg (...) function will print debugging information during compilation in debug mode and release mode.