@@ -149,6 +149,7 @@ static inline unsigned mtypesize(unsigned mtype) {
149149#define MSG_INFO (fmt ...) do { rtapi_print_msg(RTAPI_MSG_INFO, fmt); } while(0)
150150#define MSG_ERR (fmt ...) do { rtapi_print_msg(RTAPI_MSG_ERR, fmt); } while(0)
151151#define MSG_WARN (fmt ...) do { rtapi_print_msg(RTAPI_MSG_WARN, fmt); } while(0)
152+ #define MSG_PRINT (fmt ...) do { rtapi_print(fmt); } while(0)
152153
153154// State-machine states
154155enum {
@@ -2694,25 +2695,27 @@ int rtapi_app_main(void)
26942695 int retval ;
26952696
26962697 // Only touch the message level if requested
2698+ if (!debug )
2699+ MSG_PRINT (COMP_NAME ": warning: Setting debug to 0 (zero) prevents error messages from being printed\n" );
26972700 if (debug >= 0 )
26982701 rtapi_set_msg_level (debug );
26992702
27002703 if (!ports [0 ]) {
2701- MSG_ERR (COMP_NAME ": The component requires at least one valid pktuart port, eg ports=\"hm2_5i25.0.pktuart.7\"\n" );
2704+ MSG_PRINT (COMP_NAME ": error : The component requires at least one valid pktuart port, eg ports=\"hm2_5i25.0.pktuart.7\"\n" );
27022705 return - EINVAL ;
27032706 }
27042707
27052708 comp_id = hal_init (COMP_NAME );
27062709 if (comp_id < 0 ) {
2707- MSG_ERR (COMP_NAME ": hal_init() failed\n" );
2710+ MSG_PRINT (COMP_NAME ": error : hal_init() failed\n" );
27082711 return comp_id ;
27092712 }
27102713
27112714 // Count the instances.
27122715 for (mb .ninsts = 0 ; mb .ninsts < MAX_PORTS && ports [mb .ninsts ]; mb .ninsts ++ ) {}
27132716 // Allocate memory for the instances
27142717 if (!(mb .insts = (hm2_modbus_inst_t * )rtapi_kzalloc (mb .ninsts * sizeof (* mb .insts ), RTAPI_GFP_KERNEL ))) {
2715- MSG_ERR (COMP_NAME ": Allocate instance memory failed\n" );
2718+ MSG_PRINT (COMP_NAME ": error : Allocate instance memory failed\n" );
27162719 hal_exit (comp_id );
27172720 return - ENOMEM ;
27182721 }
@@ -2725,13 +2728,15 @@ int rtapi_app_main(void)
27252728 rtapi_strlcpy (inst -> uart , ports [i ], sizeof (inst -> uart )- 1 );
27262729
27272730 if (!mbccbs [i ]) {
2728- MSG_ERR ("%s: error: Missing mbccb file path for instance %d in 'mbccbs' argument\n" , inst -> name , i );
2731+ MSG_PRINT ("%s: error: Missing mbccb file path for instance %d in 'mbccbs' argument\n" , inst -> name , i );
27292732 retval = - EINVAL ;
27302733 goto errout ;
27312734 }
2735+ /*
27322736 if('/' != mbccbs[i][0]) {
2733- MSG_WARN ("%s: warning: The 'mbccb' file path '%s' for instance %d in 'mbccbs' argument is not absolute\n" , inst -> name , mbccbs [i ], i );
2737+ MSG_PRINT ("%s: warning: The 'mbccb' file path '%s' for instance %d in 'mbccbs' argument is not absolute\n", inst->name, mbccbs[i], i);
27342738 }
2739+ */
27352740
27362741 if ((retval = load_mbccb (inst , mbccbs [i ])) < 0 ) {
27372742 // Messages printed in load function
@@ -2742,33 +2747,33 @@ int rtapi_app_main(void)
27422747
27432748 // Allocate HAL memory
27442749 if (!(inst -> hal = (hm2_modbus_hal_t * )hal_malloc (sizeof (* inst -> hal )))) {
2745- MSG_ERR ("%s: error: Failed to allocate HAL memory\n" , inst -> name );
2750+ MSG_PRINT ("%s: error: Failed to allocate HAL memory\n" , inst -> name );
27462751 retval = - ENOMEM ;
27472752 goto errout ;
27482753 }
27492754 if (!(inst -> hal -> pins = (mbt_pin_hal_t * )hal_malloc (inst -> npins * sizeof (* inst -> hal -> pins )))) {
2750- MSG_ERR ("%s: error: Failed to allocate HAL pins memory\n" , inst -> name );
2755+ MSG_PRINT ("%s: error: Failed to allocate HAL pins memory\n" , inst -> name );
27512756 retval = - ENOMEM ;
27522757 goto errout ;
27532758 }
27542759 if (!(inst -> hal -> cmds = (mbt_cmd_hal_t * )hal_malloc (inst -> ncmds * sizeof (* inst -> hal -> cmds )))) {
2755- MSG_ERR ("%s: error: Failed to allocate HAL cmds memory\n" , inst -> name );
2760+ MSG_PRINT ("%s: error: Failed to allocate HAL cmds memory\n" , inst -> name );
27562761 retval = - ENOMEM ;
27572762 goto errout ;
27582763 }
27592764
27602765 if (inst -> ninit > 0 ) {
27612766 // Allocate inits memory
27622767 if (!(inst -> _init = rtapi_kzalloc (inst -> ninit * sizeof (* inst -> _init ), RTAPI_GFP_KERNEL ))) {
2763- MSG_ERR ("%s: error: Failed to allocate init commands memory\n" , inst -> name );
2768+ MSG_PRINT ("%s: error: Failed to allocate init commands memory\n" , inst -> name );
27642769 retval = - ENOMEM ;
27652770 goto errout ;
27662771 }
27672772 }
27682773
27692774 // Allocate commands memory
27702775 if (!(inst -> _cmds = rtapi_kzalloc (inst -> ncmds * sizeof (* inst -> _cmds ), RTAPI_GFP_KERNEL ))) {
2771- MSG_ERR ("%s: error: Failed to allocate commands memory\n" , inst -> name );
2776+ MSG_PRINT ("%s: error: Failed to allocate commands memory\n" , inst -> name );
27722777 retval = - ENOMEM ;
27732778 goto errout ;
27742779 }
@@ -2789,14 +2794,14 @@ int rtapi_app_main(void)
27892794
27902795 // Export the HAL process function
27912796 if ((retval = hal_export_functf (process , inst , 1 , 0 , comp_id , COMP_NAME ".%d.process" , i )) < 0 ) {
2792- MSG_ERR ("%s: error: Function export failed\n" , inst -> name );
2797+ MSG_PRINT ("%s: error: Function export failed\n" , inst -> name );
27932798 goto errout ;
27942799 }
27952800
27962801#define CHECK (x ) do { \
27972802 retval = (x); \
27982803 if(retval < 0) { \
2799- MSG_ERR ("%s: error: Failed to create pin or parameter\n", inst->name); \
2804+ MSG_PRINT ("%s: error: Failed to create pin or parameter\n", inst->name); \
28002805 goto errout; \
28012806 } \
28022807 } while(0)
@@ -2858,7 +2863,8 @@ int rtapi_app_main(void)
28582863 inst -> cfg_tx .flags |= HM2_PKTUART_CONFIG_DRIVEEN | HM2_PKTUART_CONFIG_DRIVEAUTO ;
28592864
28602865 if ((retval = hm2_pktuart_get_version (inst -> uart )) < 0 ) {
2861- MSG_ERR ("%s: error: Cannot get PktUART version (error=%d)\n" , inst -> name , retval );
2866+ MSG_PRINT ("%s: error: Cannot get PktUART version (error=%d)\n" , inst -> name , retval );
2867+ MSG_PRINT ("%s: error: probable cause: port '%s' does not exist (typo?)\n" , inst -> name , inst -> uart );
28622868 goto errout ;
28632869 }
28642870 inst -> rxversion = (retval >> 4 ) & 0x0f ;
@@ -2869,49 +2875,50 @@ int rtapi_app_main(void)
28692875 // timing measurement.
28702876 if (inst -> rxversion < 3 || inst -> txversion < 3 ) {
28712877 if (inst -> rxversion < 2 || inst -> txversion < 2 ) {
2872- MSG_ERR ("%s: error: The driver does not support PktUART versions before 2 (Rx=%u Tx=%u), aborting.\n" ,
2878+ MSG_PRINT ("%s: error: The driver does not support PktUART versions before 2 (Rx=%u Tx=%u), aborting.\n" ,
28732879 inst -> name , inst -> rxversion , inst -> txversion );
28742880 goto errout ;
28752881 }
2876- MSG_WARN ("%s: warning: PktUART version is less than 3 (Rx=%u Tx=%u). Please consider upgrading.\n" ,
2882+ MSG_PRINT ("%s: warning: PktUART version is less than 3 (Rx=%u Tx=%u). Please consider upgrading.\n" ,
28772883 inst -> name , inst -> rxversion , inst -> txversion );
28782884 if (stopbits > 1 ) {
2879- MSG_WARN ("%s: warning: Old PktUART cannot set two stop-bits. Setting to one.\n" , inst -> name );
2885+ MSG_PRINT ("%s: warning: Old PktUART cannot set two stop-bits. Setting to one.\n" , inst -> name );
28802886 stopbits = 1 ;
28812887 }
28822888 if (inst -> txversion < 3 && inst -> cfg_tx .ifdelay > 0xff ) {
2883- MSG_WARN ("%s: warning: Old PktUART cannot set txdelay to 0x%04x. Clamping to 0xff.\n" ,
2889+ MSG_PRINT ("%s: warning: Old PktUART cannot set txdelay to 0x%04x. Clamping to 0xff.\n" ,
28842890 inst -> name , inst -> cfg_tx .ifdelay );
28852891 inst -> cfg_tx .ifdelay = 0xff ;
28862892 }
28872893 if (inst -> rxversion < 3 && inst -> cfg_rx .ifdelay > 0xff ) {
2888- MSG_WARN ("%s: warning: Old PktUART cannot set rxdelay to 0x%04x. Clamping to 0xff.\n" ,
2894+ MSG_PRINT ("%s: warning: Old PktUART cannot set rxdelay to 0x%04x. Clamping to 0xff.\n" ,
28892895 inst -> name , inst -> cfg_rx .ifdelay );
28902896 inst -> cfg_rx .ifdelay = 0xff ;
28912897 }
28922898 if (inst -> rxversion < 3 && inst -> mbccb -> icdelay != 0 ) {
2893- MSG_WARN ("%s: warning: Old PktUART cannot set icdelay, disabling.\n" , inst -> name );
2899+ MSG_PRINT ("%s: warning: Old PktUART cannot set icdelay, disabling.\n" , inst -> name );
28942900 inst -> mbccb -> icdelay = 0 ;
28952901 }
28962902 }
28972903
28982904 setup_icdelay (inst , inst -> mbccb -> baudrate , parity , stopbits , inst -> mbccb -> icdelay );
28992905
29002906#ifdef DEBUG
2901- MSG_INFO ("%s: inst->name : %s\n" , inst -> name , inst -> name );
2902- MSG_INFO ("%s: inst->uart : %s\n" , inst -> name , inst -> uart );
2903- MSG_INFO ("%s: inst->mbccbsize: %zd\n" , inst -> name , inst -> mbccbsize );
2904- MSG_INFO ("%s: inst->ninit : %u\n" , inst -> name , inst -> ninit );
2905- MSG_INFO ("%s: inst->ncmds : %u\n" , inst -> name , inst -> ncmds );
2906- MSG_INFO ("%s: inst->npins : %u\n" , inst -> name , inst -> npins );
2907- MSG_INFO ("%s: inst->icdelay : %u\n" , inst -> name , inst -> maxicharbits );
2908- MSG_INFO ("%s: inst->rxdelay : %u\n" , inst -> name , inst -> cfg_rx .ifdelay );
2909- MSG_INFO ("%s: inst->txdelay : %u\n" , inst -> name , inst -> cfg_tx .ifdelay );
2910- MSG_INFO ("%s: inst->drvdelay : %u\n" , inst -> name , inst -> cfg_tx .drivedelay );
2907+ MSG_PRINT ("%s: inst->name : %s\n" , inst -> name , inst -> name );
2908+ MSG_PRINT ("%s: inst->uart : %s\n" , inst -> name , inst -> uart );
2909+ MSG_PRINT ("%s: inst->mbccbsize: %zd\n" , inst -> name , inst -> mbccbsize );
2910+ MSG_PRINT ("%s: inst->ninit : %u\n" , inst -> name , inst -> ninit );
2911+ MSG_PRINT ("%s: inst->ncmds : %u\n" , inst -> name , inst -> ncmds );
2912+ MSG_PRINT ("%s: inst->npins : %u\n" , inst -> name , inst -> npins );
2913+ MSG_PRINT ("%s: inst->icdelay : %u\n" , inst -> name , inst -> maxicharbits );
2914+ MSG_PRINT ("%s: inst->rxdelay : %u\n" , inst -> name , inst -> cfg_rx .ifdelay );
2915+ MSG_PRINT ("%s: inst->txdelay : %u\n" , inst -> name , inst -> cfg_tx .ifdelay );
2916+ MSG_PRINT ("%s: inst->drvdelay : %u\n" , inst -> name , inst -> cfg_tx .drivedelay );
29112917#endif
29122918
2913- MSG_INFO ("%s: PktUART serial configured to 8%c%c@%d\n" ,
2919+ MSG_PRINT ("%s: PktUART serial port '%s' configured to 8%c%c@%d\n" ,
29142920 inst -> name ,
2921+ inst -> uart ,
29152922 parity ? (parity == 2 ? 'E' : 'O' ) : 'N' ,
29162923 stopbits > 1 ? '2' : '1' ,
29172924 inst -> cfg_rx .baudrate );
@@ -3100,7 +3107,7 @@ int rtapi_app_main(void)
31003107 inst -> cfg_rx .flags |= HM2_PKTUART_CONFIG_FLUSH ;
31013108 inst -> cfg_tx .flags |= HM2_PKTUART_CONFIG_FLUSH ;
31023109 if ((retval = hm2_pktuart_config (inst -> uart , & inst -> cfg_rx , & inst -> cfg_tx , 0 )) < 0 ) {
3103- MSG_ERR ("%s: error: PktUART setup problem: error=%d\n" , inst -> name , retval );
3110+ MSG_PRINT ("%s: error: PktUART setup problem: error=%d\n" , inst -> name , retval );
31043111 goto errout ;
31053112 }
31063113 inst -> cfg_rx .flags &= ~HM2_PKTUART_CONFIG_FLUSH ;
0 commit comments