@@ -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 {
@@ -2625,25 +2626,27 @@ int rtapi_app_main(void)
26252626 int retval ;
26262627
26272628 // Only touch the message level if requested
2629+ if (!debug )
2630+ MSG_PRINT (COMP_NAME ": warning: Setting debug to 0 (zero) prevents error messages from being printed\n" );
26282631 if (debug >= 0 )
26292632 rtapi_set_msg_level (debug );
26302633
26312634 if (!ports [0 ]) {
2632- MSG_ERR (COMP_NAME ": The component requires at least one valid pktuart port, eg ports=\"hm2_5i25.0.pktuart.7\"\n" );
2635+ MSG_PRINT (COMP_NAME ": error : The component requires at least one valid pktuart port, eg ports=\"hm2_5i25.0.pktuart.7\"\n" );
26332636 return - EINVAL ;
26342637 }
26352638
26362639 comp_id = hal_init (COMP_NAME );
26372640 if (comp_id < 0 ) {
2638- MSG_ERR (COMP_NAME ": hal_init() failed\n" );
2641+ MSG_PRINT (COMP_NAME ": error : hal_init() failed\n" );
26392642 return comp_id ;
26402643 }
26412644
26422645 // Count the instances.
26432646 for (mb .ninsts = 0 ; mb .ninsts < MAX_PORTS && ports [mb .ninsts ]; mb .ninsts ++ ) {}
26442647 // Allocate memory for the instances
26452648 if (!(mb .insts = (hm2_modbus_inst_t * )rtapi_kzalloc (mb .ninsts * sizeof (* mb .insts ), RTAPI_GFP_KERNEL ))) {
2646- MSG_ERR (COMP_NAME ": Allocate instance memory failed\n" );
2649+ MSG_PRINT (COMP_NAME ": error : Allocate instance memory failed\n" );
26472650 hal_exit (comp_id );
26482651 return - ENOMEM ;
26492652 }
@@ -2656,13 +2659,15 @@ int rtapi_app_main(void)
26562659 rtapi_strlcpy (inst -> uart , ports [i ], sizeof (inst -> uart )- 1 );
26572660
26582661 if (!mbccbs [i ]) {
2659- MSG_ERR ("%s: error: Missing mbccb file path for instance %d in 'mbccbs' argument\n" , inst -> name , i );
2662+ MSG_PRINT ("%s: error: Missing mbccb file path for instance %d in 'mbccbs' argument\n" , inst -> name , i );
26602663 retval = - EINVAL ;
26612664 goto errout ;
26622665 }
2666+ /*
26632667 if('/' != mbccbs[i][0]) {
2664- MSG_WARN ("%s: warning: The 'mbccb' file path '%s' for instance %d in 'mbccbs' argument is not absolute\n" , inst -> name , mbccbs [i ], i );
2668+ MSG_PRINT ("%s: warning: The 'mbccb' file path '%s' for instance %d in 'mbccbs' argument is not absolute\n", inst->name, mbccbs[i], i);
26652669 }
2670+ */
26662671
26672672 if ((retval = load_mbccb (inst , mbccbs [i ])) < 0 ) {
26682673 // Messages printed in load function
@@ -2673,33 +2678,33 @@ int rtapi_app_main(void)
26732678
26742679 // Allocate HAL memory
26752680 if (!(inst -> hal = (hm2_modbus_hal_t * )hal_malloc (sizeof (* inst -> hal )))) {
2676- MSG_ERR ("%s: error: Failed to allocate HAL memory\n" , inst -> name );
2681+ MSG_PRINT ("%s: error: Failed to allocate HAL memory\n" , inst -> name );
26772682 retval = - ENOMEM ;
26782683 goto errout ;
26792684 }
26802685 if (!(inst -> hal -> pins = (mbt_pin_hal_t * )hal_malloc (inst -> npins * sizeof (* inst -> hal -> pins )))) {
2681- MSG_ERR ("%s: error: Failed to allocate HAL pins memory\n" , inst -> name );
2686+ MSG_PRINT ("%s: error: Failed to allocate HAL pins memory\n" , inst -> name );
26822687 retval = - ENOMEM ;
26832688 goto errout ;
26842689 }
26852690 if (!(inst -> hal -> cmds = (mbt_cmd_hal_t * )hal_malloc (inst -> ncmds * sizeof (* inst -> hal -> cmds )))) {
2686- MSG_ERR ("%s: error: Failed to allocate HAL cmds memory\n" , inst -> name );
2691+ MSG_PRINT ("%s: error: Failed to allocate HAL cmds memory\n" , inst -> name );
26872692 retval = - ENOMEM ;
26882693 goto errout ;
26892694 }
26902695
26912696 if (inst -> ninit > 0 ) {
26922697 // Allocate inits memory
26932698 if (!(inst -> _init = rtapi_kzalloc (inst -> ninit * sizeof (* inst -> _init ), RTAPI_GFP_KERNEL ))) {
2694- MSG_ERR ("%s: error: Failed to allocate init commands memory\n" , inst -> name );
2699+ MSG_PRINT ("%s: error: Failed to allocate init commands memory\n" , inst -> name );
26952700 retval = - ENOMEM ;
26962701 goto errout ;
26972702 }
26982703 }
26992704
27002705 // Allocate commands memory
27012706 if (!(inst -> _cmds = rtapi_kzalloc (inst -> ncmds * sizeof (* inst -> _cmds ), RTAPI_GFP_KERNEL ))) {
2702- MSG_ERR ("%s: error: Failed to allocate commands memory\n" , inst -> name );
2707+ MSG_PRINT ("%s: error: Failed to allocate commands memory\n" , inst -> name );
27032708 retval = - ENOMEM ;
27042709 goto errout ;
27052710 }
@@ -2722,14 +2727,14 @@ int rtapi_app_main(void)
27222727 char pname [HAL_NAME_LEN + 1 ];
27232728 rtapi_snprintf (pname , sizeof (pname ), COMP_NAME ".%d.process" , i );
27242729 if ((retval = hal_export_funct (pname , process , inst , 1 , 0 , comp_id )) < 0 ) {
2725- MSG_ERR ("%s: error: Function export failed\n" , inst -> name );
2730+ MSG_PRINT ("%s: error: Function export failed\n" , inst -> name );
27262731 goto errout ;
27272732 }
27282733
27292734#define CHECK (x ) do { \
27302735 retval = (x); \
27312736 if(retval < 0) { \
2732- MSG_ERR ("%s: error: Failed to create pin or parameter\n", inst->name); \
2737+ MSG_PRINT ("%s: error: Failed to create pin or parameter\n", inst->name); \
27332738 goto errout; \
27342739 } \
27352740 } while(0)
@@ -2791,7 +2796,8 @@ int rtapi_app_main(void)
27912796 inst -> cfg_tx .flags |= HM2_PKTUART_CONFIG_DRIVEEN | HM2_PKTUART_CONFIG_DRIVEAUTO ;
27922797
27932798 if ((retval = hm2_pktuart_get_version (inst -> uart )) < 0 ) {
2794- MSG_ERR ("%s: error: Cannot get PktUART version (error=%d)\n" , inst -> name , retval );
2799+ MSG_PRINT ("%s: error: Cannot get PktUART version (error=%d)\n" , inst -> name , retval );
2800+ MSG_PRINT ("%s: error: probable cause: port '%s' does not exist (typo?)\n" , inst -> name , inst -> uart );
27952801 goto errout ;
27962802 }
27972803 inst -> rxversion = (retval >> 4 ) & 0x0f ;
@@ -2802,49 +2808,50 @@ int rtapi_app_main(void)
28022808 // timing measurement.
28032809 if (inst -> rxversion < 3 || inst -> txversion < 3 ) {
28042810 if (inst -> rxversion < 2 || inst -> txversion < 2 ) {
2805- MSG_ERR ("%s: error: The driver does not support PktUART versions before 2 (Rx=%u Tx=%u), aborting.\n" ,
2811+ MSG_PRINT ("%s: error: The driver does not support PktUART versions before 2 (Rx=%u Tx=%u), aborting.\n" ,
28062812 inst -> name , inst -> rxversion , inst -> txversion );
28072813 goto errout ;
28082814 }
2809- MSG_WARN ("%s: warning: PktUART version is less than 3 (Rx=%u Tx=%u). Please consider upgrading.\n" ,
2815+ MSG_PRINT ("%s: warning: PktUART version is less than 3 (Rx=%u Tx=%u). Please consider upgrading.\n" ,
28102816 inst -> name , inst -> rxversion , inst -> txversion );
28112817 if (stopbits > 1 ) {
2812- MSG_WARN ("%s: warning: Old PktUART cannot set two stop-bits. Setting to one.\n" , inst -> name );
2818+ MSG_PRINT ("%s: warning: Old PktUART cannot set two stop-bits. Setting to one.\n" , inst -> name );
28132819 stopbits = 1 ;
28142820 }
28152821 if (inst -> txversion < 3 && inst -> cfg_tx .ifdelay > 0xff ) {
2816- MSG_WARN ("%s: warning: Old PktUART cannot set txdelay to 0x%04x. Clamping to 0xff.\n" ,
2822+ MSG_PRINT ("%s: warning: Old PktUART cannot set txdelay to 0x%04x. Clamping to 0xff.\n" ,
28172823 inst -> name , inst -> cfg_tx .ifdelay );
28182824 inst -> cfg_tx .ifdelay = 0xff ;
28192825 }
28202826 if (inst -> rxversion < 3 && inst -> cfg_rx .ifdelay > 0xff ) {
2821- MSG_WARN ("%s: warning: Old PktUART cannot set rxdelay to 0x%04x. Clamping to 0xff.\n" ,
2827+ MSG_PRINT ("%s: warning: Old PktUART cannot set rxdelay to 0x%04x. Clamping to 0xff.\n" ,
28222828 inst -> name , inst -> cfg_rx .ifdelay );
28232829 inst -> cfg_rx .ifdelay = 0xff ;
28242830 }
28252831 if (inst -> rxversion < 3 && inst -> mbccb -> icdelay != 0 ) {
2826- MSG_WARN ("%s: warning: Old PktUART cannot set icdelay, disabling.\n" , inst -> name );
2832+ MSG_PRINT ("%s: warning: Old PktUART cannot set icdelay, disabling.\n" , inst -> name );
28272833 inst -> mbccb -> icdelay = 0 ;
28282834 }
28292835 }
28302836
28312837 setup_icdelay (inst , inst -> mbccb -> baudrate , parity , stopbits , inst -> mbccb -> icdelay );
28322838
28332839#ifdef DEBUG
2834- MSG_INFO ("%s: inst->name : %s\n" , inst -> name , inst -> name );
2835- MSG_INFO ("%s: inst->uart : %s\n" , inst -> name , inst -> uart );
2836- MSG_INFO ("%s: inst->mbccbsize: %zd\n" , inst -> name , inst -> mbccbsize );
2837- MSG_INFO ("%s: inst->ninit : %u\n" , inst -> name , inst -> ninit );
2838- MSG_INFO ("%s: inst->ncmds : %u\n" , inst -> name , inst -> ncmds );
2839- MSG_INFO ("%s: inst->npins : %u\n" , inst -> name , inst -> npins );
2840- MSG_INFO ("%s: inst->icdelay : %u\n" , inst -> name , inst -> maxicharbits );
2841- MSG_INFO ("%s: inst->rxdelay : %u\n" , inst -> name , inst -> cfg_rx .ifdelay );
2842- MSG_INFO ("%s: inst->txdelay : %u\n" , inst -> name , inst -> cfg_tx .ifdelay );
2843- MSG_INFO ("%s: inst->drvdelay : %u\n" , inst -> name , inst -> cfg_tx .drivedelay );
2840+ MSG_PRINT ("%s: inst->name : %s\n" , inst -> name , inst -> name );
2841+ MSG_PRINT ("%s: inst->uart : %s\n" , inst -> name , inst -> uart );
2842+ MSG_PRINT ("%s: inst->mbccbsize: %zd\n" , inst -> name , inst -> mbccbsize );
2843+ MSG_PRINT ("%s: inst->ninit : %u\n" , inst -> name , inst -> ninit );
2844+ MSG_PRINT ("%s: inst->ncmds : %u\n" , inst -> name , inst -> ncmds );
2845+ MSG_PRINT ("%s: inst->npins : %u\n" , inst -> name , inst -> npins );
2846+ MSG_PRINT ("%s: inst->icdelay : %u\n" , inst -> name , inst -> maxicharbits );
2847+ MSG_PRINT ("%s: inst->rxdelay : %u\n" , inst -> name , inst -> cfg_rx .ifdelay );
2848+ MSG_PRINT ("%s: inst->txdelay : %u\n" , inst -> name , inst -> cfg_tx .ifdelay );
2849+ MSG_PRINT ("%s: inst->drvdelay : %u\n" , inst -> name , inst -> cfg_tx .drivedelay );
28442850#endif
28452851
2846- MSG_INFO ("%s: PktUART serial configured to 8%c%c@%d\n" ,
2852+ MSG_PRINT ("%s: PktUART serial port '%s' configured to 8%c%c@%d\n" ,
28472853 inst -> name ,
2854+ inst -> uart ,
28482855 parity ? (parity == 2 ? 'E' : 'O' ) : 'N' ,
28492856 stopbits > 1 ? '2' : '1' ,
28502857 inst -> cfg_rx .baudrate );
@@ -2997,7 +3004,7 @@ int rtapi_app_main(void)
29973004 inst -> cfg_rx .flags |= HM2_PKTUART_CONFIG_FLUSH ;
29983005 inst -> cfg_tx .flags |= HM2_PKTUART_CONFIG_FLUSH ;
29993006 if ((retval = hm2_pktuart_config (inst -> uart , & inst -> cfg_rx , & inst -> cfg_tx , 0 )) < 0 ) {
3000- MSG_ERR ("%s: error: PktUART setup problem: error=%d\n" , inst -> name , retval );
3007+ MSG_PRINT ("%s: error: PktUART setup problem: error=%d\n" , inst -> name , retval );
30013008 goto errout ;
30023009 }
30033010 inst -> cfg_rx .flags &= ~HM2_PKTUART_CONFIG_FLUSH ;
0 commit comments