refclock_jjy.c (285169) | refclock_jjy.c (294554) |
---|---|
1/* 2 * refclock_jjy - clock driver for JJY receivers 3 */ 4 5/**********************************************************************/ 6/* */ 7/* Copyright (C) 2001-2015, Takao Abe. All rights reserved. */ 8/* */ --- 135 unchanged lines hidden (view full) --- 144#define DESCRIPTION "JJY Receiver" 145#define PRECISION (-3) /* precision assumed (about 100 ms) */ 146 147/* 148 * JJY unit control structure 149 */ 150 151struct jjyRawDataBreak { | 1/* 2 * refclock_jjy - clock driver for JJY receivers 3 */ 4 5/**********************************************************************/ 6/* */ 7/* Copyright (C) 2001-2015, Takao Abe. All rights reserved. */ 8/* */ --- 135 unchanged lines hidden (view full) --- 144#define DESCRIPTION "JJY Receiver" 145#define PRECISION (-3) /* precision assumed (about 100 ms) */ 146 147/* 148 * JJY unit control structure 149 */ 150 151struct jjyRawDataBreak { |
152 char *pString ; 153 int iLength ; | 152 const char * pString ; 153 int iLength ; |
154} ; 155 156#define MAX_TIMESTAMP 6 157#define MAX_RAWBUF 100 158#define MAX_LOOPBACK 5 159 160struct jjyunit { 161/* Set up by the function "jjy_start_xxxxxxxx" */ --- 460 unchanged lines hidden (view full) --- 622 } else { 623 624 pp->lencode = refclock_gtlin ( rbufp, pp->a_lastcode, BMAX, &tRecvTimestamp ) ; 625 626 } 627#ifdef DEBUG 628 printf( "\nrefclock_jjy.c : %s : Len=%d ", sFunctionName, pp->lencode ) ; 629 for ( i = 0 ; i < pp->lencode ; i ++ ) { | 154} ; 155 156#define MAX_TIMESTAMP 6 157#define MAX_RAWBUF 100 158#define MAX_LOOPBACK 5 159 160struct jjyunit { 161/* Set up by the function "jjy_start_xxxxxxxx" */ --- 460 unchanged lines hidden (view full) --- 622 } else { 623 624 pp->lencode = refclock_gtlin ( rbufp, pp->a_lastcode, BMAX, &tRecvTimestamp ) ; 625 626 } 627#ifdef DEBUG 628 printf( "\nrefclock_jjy.c : %s : Len=%d ", sFunctionName, pp->lencode ) ; 629 for ( i = 0 ; i < pp->lencode ; i ++ ) { |
630 if ( iscntrl( pp->a_lastcode[i] & 0x7F ) ) { | 630 if ( iscntrl( (u_char)(pp->a_lastcode[i] & 0x7F) ) ) { |
631 printf( "<x%02X>", pp->a_lastcode[i] & 0xFF ) ; 632 } else { 633 printf( "%c", pp->a_lastcode[i] ) ; 634 } 635 } 636 printf( "\n" ) ; 637#endif 638 --- 58 unchanged lines hidden (view full) --- 697 up->iLineBufLen = up->iTextBufLen = 0 ; 698 for ( i = iReadRawBuf ; i <= iBreakPosition ; i ++ ) { 699 700 /* Copy all characters */ 701 up->sLineBuf[up->iLineBufLen] = up->sRawBuf[i] ; 702 up->iLineBufLen ++ ; 703 704 /* Copy printable characters */ | 631 printf( "<x%02X>", pp->a_lastcode[i] & 0xFF ) ; 632 } else { 633 printf( "%c", pp->a_lastcode[i] ) ; 634 } 635 } 636 printf( "\n" ) ; 637#endif 638 --- 58 unchanged lines hidden (view full) --- 697 up->iLineBufLen = up->iTextBufLen = 0 ; 698 for ( i = iReadRawBuf ; i <= iBreakPosition ; i ++ ) { 699 700 /* Copy all characters */ 701 up->sLineBuf[up->iLineBufLen] = up->sRawBuf[i] ; 702 up->iLineBufLen ++ ; 703 704 /* Copy printable characters */ |
705 if ( ! iscntrl( up->sRawBuf[i] ) ) { | 705 if ( ! iscntrl( (u_char)up->sRawBuf[i] ) ) { |
706 up->sTextBuf[up->iTextBufLen] = up->sRawBuf[i] ; 707 up->iTextBufLen ++ ; 708 } 709 710 } 711 up->sLineBuf[up->iLineBufLen] = 0 ; 712 up->sTextBuf[up->iTextBufLen] = 0 ; 713#ifdef DEBUG --- 435 unchanged lines hidden (view full) --- 1149 1150static int 1151jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp ) 1152{ 1153 struct jjyunit *up ; 1154 struct refclockproc *pp ; 1155 struct peer *peer; 1156 | 706 up->sTextBuf[up->iTextBufLen] = up->sRawBuf[i] ; 707 up->iTextBufLen ++ ; 708 } 709 710 } 711 up->sLineBuf[up->iLineBufLen] = 0 ; 712 up->sTextBuf[up->iTextBufLen] = 0 ; 713#ifdef DEBUG --- 435 unchanged lines hidden (view full) --- 1149 1150static int 1151jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp ) 1152{ 1153 struct jjyunit *up ; 1154 struct refclockproc *pp ; 1155 struct peer *peer; 1156 |
1157 char *pBuf, sLog [ 100 ] ; 1158 int iLen ; 1159 int rc ; | 1157 char * pBuf ; 1158 char sLog [ 100 ] ; 1159 int iLen ; 1160 int rc ; |
1160 | 1161 |
1161 const char *pCmd ; 1162 int iCmdLen ; | 1162 const char * pCmd ; 1163 int iCmdLen ; |
1163 1164 /* Initialize pointers */ 1165 1166 peer = rbufp->recv_peer ; 1167 pp = peer->procptr ; 1168 up = pp->unitptr ; 1169 1170 if ( up->linediscipline == LDISC_RAW ) { --- 183 unchanged lines hidden (view full) --- 1354{ 1355#ifdef DEBUG 1356 static const char *sFunctionName = "jjy_poll_tristate_jjy01" ; 1357#endif 1358 1359 struct refclockproc *pp ; 1360 struct jjyunit *up ; 1361 | 1164 1165 /* Initialize pointers */ 1166 1167 peer = rbufp->recv_peer ; 1168 pp = peer->procptr ; 1169 up = pp->unitptr ; 1170 1171 if ( up->linediscipline == LDISC_RAW ) { --- 183 unchanged lines hidden (view full) --- 1355{ 1356#ifdef DEBUG 1357 static const char *sFunctionName = "jjy_poll_tristate_jjy01" ; 1358#endif 1359 1360 struct refclockproc *pp ; 1361 struct jjyunit *up ; 1362 |
1362 const char *pCmd ; 1363 int iCmdLen ; | 1363 const char * pCmd ; 1364 int iCmdLen ; |
1364 1365 pp = peer->procptr; 1366 up = pp->unitptr ; 1367 1368 up->bLineError = FALSE ; 1369 up->iTimestampCount = 0 ; 1370 1371 if ( ( pp->sloppyclockflag & CLK_FLAG1 ) == 0 ) { --- 633 unchanged lines hidden (view full) --- 2005#ifdef DEBUG 2006 static const char *sFunctionName = "jjy_receive_tristate_gpsclock01" ; 2007#endif 2008 2009 struct jjyunit *up ; 2010 struct refclockproc *pp ; 2011 struct peer *peer; 2012 | 1365 1366 pp = peer->procptr; 1367 up = pp->unitptr ; 1368 1369 up->bLineError = FALSE ; 1370 up->iTimestampCount = 0 ; 1371 1372 if ( ( pp->sloppyclockflag & CLK_FLAG1 ) == 0 ) { --- 633 unchanged lines hidden (view full) --- 2006#ifdef DEBUG 2007 static const char *sFunctionName = "jjy_receive_tristate_gpsclock01" ; 2008#endif 2009 2010 struct jjyunit *up ; 2011 struct refclockproc *pp ; 2012 struct peer *peer; 2013 |
2013 char *pBuf, sLog [ 100 ] ; 2014 int iLen ; 2015 int rc ; | 2014 char * pBuf ; 2015 char sLog [ 100 ] ; 2016 int iLen ; 2017 int rc ; |
2016 | 2018 |
2017 const char *pCmd ; 2018 int iCmdLen ; | 2019 const char * pCmd ; 2020 int iCmdLen ; |
2019 2020 /* Initialize pointers */ 2021 2022 peer = rbufp->recv_peer ; 2023 pp = peer->procptr ; 2024 up = pp->unitptr ; 2025 2026 if ( up->linediscipline == LDISC_RAW ) { --- 207 unchanged lines hidden (view full) --- 2234{ 2235#ifdef DEBUG 2236 static const char *sFunctionName = "jjy_poll_tristate_gpsclock01" ; 2237#endif 2238 2239 struct refclockproc *pp ; 2240 struct jjyunit *up ; 2241 | 2021 2022 /* Initialize pointers */ 2023 2024 peer = rbufp->recv_peer ; 2025 pp = peer->procptr ; 2026 up = pp->unitptr ; 2027 2028 if ( up->linediscipline == LDISC_RAW ) { --- 207 unchanged lines hidden (view full) --- 2236{ 2237#ifdef DEBUG 2238 static const char *sFunctionName = "jjy_poll_tristate_gpsclock01" ; 2239#endif 2240 2241 struct refclockproc *pp ; 2242 struct jjyunit *up ; 2243 |
2242 const char *pCmd ; 2243 int iCmdLen ; | 2244 const char * pCmd ; 2245 int iCmdLen ; |
2244 2245 pp = peer->procptr ; 2246 up = pp->unitptr ; 2247 2248 up->iTimestampCount = 0 ; 2249 2250 if ( ( pp->sloppyclockflag & CLK_FLAG1 ) == 0 ) { 2251 /* Skip "stus" command */ --- 319 unchanged lines hidden (view full) --- 2571static int teljjy_conn_send ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2572static int teljjy_conn_data ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2573static int teljjy_conn_silent ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2574static int teljjy_conn_error ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2575static int teljjy_bye_ignore ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2576static int teljjy_bye_disc ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2577static int teljjy_bye_modem ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2578 | 2246 2247 pp = peer->procptr ; 2248 up = pp->unitptr ; 2249 2250 up->iTimestampCount = 0 ; 2251 2252 if ( ( pp->sloppyclockflag & CLK_FLAG1 ) == 0 ) { 2253 /* Skip "stus" command */ --- 319 unchanged lines hidden (view full) --- 2573static int teljjy_conn_send ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2574static int teljjy_conn_data ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2575static int teljjy_conn_silent ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2576static int teljjy_conn_error ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2577static int teljjy_bye_ignore ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2578static int teljjy_bye_disc ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2579static int teljjy_bye_modem ( struct peer *peer, struct refclockproc *, struct jjyunit * ) ; 2580 |
2579static int ( *pTeljjyHandler [ ] [ 5 ] ) ( ) = | 2581static int ( *pTeljjyHandler [ ] [ 5 ] ) ( struct peer *, struct refclockproc *, struct jjyunit *) = |
2580{ /*STATE_IDLE STATE_DAILOUT STATE_LOGIN STATE_CONNECT STATE_BYE */ 2581/* NULL */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_ignore }, 2582/* START */ { teljjy_idle_dialout, teljjy_dial_ignore, teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_ignore }, 2583/* CONNECT */ { teljjy_idle_ignore , teljjy_dial_login , teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_ignore }, 2584/* DISCONNECT */ { teljjy_idle_ignore , teljjy_dial_disc , teljjy_login_disc , teljjy_conn_disc , teljjy_bye_disc }, 2585/* COMMAND */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_modem }, 2586/* LOGIN */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_login , teljjy_conn_error , teljjy_bye_ignore }, 2587/* PROMPT */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_conn , teljjy_conn_send , teljjy_bye_ignore }, --- 122 unchanged lines hidden (view full) --- 2710 if ( sys_phone[1] != NULL ) { 2711 msyslog( LOG_ERR, "refclock_jjy.c : jjy_start_telephone : phone in the ntpd.conf should be only one." ) ; 2712 up->bInitError = TRUE ; 2713 return 1 ; 2714 } 2715 2716 iNumberOfDigitsOfPhoneNumber = iCommaCount = iCommaPosition = iFirstThreeDigitsCount = 0 ; 2717 for ( i = 0 ; i < strlen( sys_phone[0] ) ; i ++ ) { | 2582{ /*STATE_IDLE STATE_DAILOUT STATE_LOGIN STATE_CONNECT STATE_BYE */ 2583/* NULL */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_ignore }, 2584/* START */ { teljjy_idle_dialout, teljjy_dial_ignore, teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_ignore }, 2585/* CONNECT */ { teljjy_idle_ignore , teljjy_dial_login , teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_ignore }, 2586/* DISCONNECT */ { teljjy_idle_ignore , teljjy_dial_disc , teljjy_login_disc , teljjy_conn_disc , teljjy_bye_disc }, 2587/* COMMAND */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_ignore, teljjy_conn_ignore, teljjy_bye_modem }, 2588/* LOGIN */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_login , teljjy_conn_error , teljjy_bye_ignore }, 2589/* PROMPT */ { teljjy_idle_ignore , teljjy_dial_ignore, teljjy_login_conn , teljjy_conn_send , teljjy_bye_ignore }, --- 122 unchanged lines hidden (view full) --- 2712 if ( sys_phone[1] != NULL ) { 2713 msyslog( LOG_ERR, "refclock_jjy.c : jjy_start_telephone : phone in the ntpd.conf should be only one." ) ; 2714 up->bInitError = TRUE ; 2715 return 1 ; 2716 } 2717 2718 iNumberOfDigitsOfPhoneNumber = iCommaCount = iCommaPosition = iFirstThreeDigitsCount = 0 ; 2719 for ( i = 0 ; i < strlen( sys_phone[0] ) ; i ++ ) { |
2718 if ( isdigit( *(sys_phone[0]+i) ) ) { | 2720 if ( isdigit( (u_char)sys_phone[0][i] ) ) { |
2719 if ( iFirstThreeDigitsCount < sizeof(sFirstThreeDigits)-1 ) { | 2721 if ( iFirstThreeDigitsCount < sizeof(sFirstThreeDigits)-1 ) { |
2720 sFirstThreeDigits[iFirstThreeDigitsCount++] = *(sys_phone[0]+i) ; | 2722 sFirstThreeDigits[iFirstThreeDigitsCount++] = sys_phone[0][i] ; |
2721 } 2722 iNumberOfDigitsOfPhoneNumber ++ ; | 2723 } 2724 iNumberOfDigitsOfPhoneNumber ++ ; |
2723 } else if ( *(sys_phone[0]+i) == ',' ) { | 2725 } else if ( sys_phone[0][i] == ',' ) { |
2724 iCommaCount ++ ; 2725 if ( iCommaCount > 1 ) { 2726 msyslog( LOG_ERR, "refclock_jjy.c : jjy_start_telephone : phone in the ntpd.conf should be zero or one comma." ) ; 2727 up->bInitError = TRUE ; 2728 return 1 ; 2729 } 2730 iFirstThreeDigitsCount = 0 ; 2731 iCommaPosition = i ; | 2726 iCommaCount ++ ; 2727 if ( iCommaCount > 1 ) { 2728 msyslog( LOG_ERR, "refclock_jjy.c : jjy_start_telephone : phone in the ntpd.conf should be zero or one comma." ) ; 2729 up->bInitError = TRUE ; 2730 return 1 ; 2731 } 2732 iFirstThreeDigitsCount = 0 ; 2733 iCommaPosition = i ; |
2732 } else if ( *(sys_phone[0]+i) != '-' ) { | 2734 } else if ( sys_phone[0][i] != '-' ) { |
2733 msyslog( LOG_ERR, "refclock_jjy.c : jjy_start_telephone : phone in the ntpd.conf should be a number or a hyphen." ) ; 2734 up->bInitError = TRUE ; 2735 return 1 ; 2736 } 2737 } 2738 sFirstThreeDigits[iFirstThreeDigitsCount] = 0 ; 2739 2740 if ( iCommaCount == 1 ) { --- 467 unchanged lines hidden (view full) --- 3208 3209} 3210 3211/******************************/ 3212static int 3213teljjy_login_login ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) 3214{ 3215 | 2735 msyslog( LOG_ERR, "refclock_jjy.c : jjy_start_telephone : phone in the ntpd.conf should be a number or a hyphen." ) ; 2736 up->bInitError = TRUE ; 2737 return 1 ; 2738 } 2739 } 2740 sFirstThreeDigits[iFirstThreeDigitsCount] = 0 ; 2741 2742 if ( iCommaCount == 1 ) { --- 467 unchanged lines hidden (view full) --- 3210 3211} 3212 3213/******************************/ 3214static int 3215teljjy_login_login ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) 3216{ 3217 |
3216 char *pCmd ; 3217 int iCmdLen ; | 3218 const char * pCmd ; 3219 int iCmdLen ; |
3218 3219 DEBUG_TELJJY_PRINTF( "teljjy_login_login" ) ; 3220 3221 /* Send a guest user ID */ 3222 pCmd = "TJJY\r" ; 3223 3224 /* Send login ID */ 3225 iCmdLen = strlen( pCmd ) ; --- 59 unchanged lines hidden (view full) --- 3285 3286} 3287 3288/******************************/ 3289static int 3290teljjy_conn_send ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) 3291{ 3292 | 3220 3221 DEBUG_TELJJY_PRINTF( "teljjy_login_login" ) ; 3222 3223 /* Send a guest user ID */ 3224 pCmd = "TJJY\r" ; 3225 3226 /* Send login ID */ 3227 iCmdLen = strlen( pCmd ) ; --- 59 unchanged lines hidden (view full) --- 3287 3288} 3289 3290/******************************/ 3291static int 3292teljjy_conn_send ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) 3293{ 3294 |
3293 const char *pCmd ; 3294 int i, iLen, iNextClockState ; | 3295 const char * pCmd ; 3296 int i, iLen, iNextClockState ; |
3295 3296 DEBUG_TELJJY_PRINTF( "teljjy_conn_send" ) ; 3297 3298 if ( up->iClockCommandSeq > 0 3299 && teljjy_command_sequence[up->iClockCommandSeq].command == NULL ) { 3300 /* Command sequence has been completed */ 3301 return TELJJY_CHANGE_CLOCK_STATE ; 3302 } --- 219 unchanged lines hidden (view full) --- 3522 3523} 3524 3525/******************************/ 3526static int 3527teljjy_conn_silent ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) 3528{ 3529 | 3297 3298 DEBUG_TELJJY_PRINTF( "teljjy_conn_send" ) ; 3299 3300 if ( up->iClockCommandSeq > 0 3301 && teljjy_command_sequence[up->iClockCommandSeq].command == NULL ) { 3302 /* Command sequence has been completed */ 3303 return TELJJY_CHANGE_CLOCK_STATE ; 3304 } --- 219 unchanged lines hidden (view full) --- 3524 3525} 3526 3527/******************************/ 3528static int 3529teljjy_conn_silent ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) 3530{ 3531 |
3530 const char *pCmd ; | 3532 const char * pCmd ; |
3531 3532 DEBUG_TELJJY_PRINTF( "teljjy_conn_silent" ) ; 3533 3534 if ( up->iClockCommandSeq >= 1 3535 && up->iClockCommandSeq < TELJJY_COMMAND_START_SKIP_LOOPBACK ) { 3536 /* Loopback */ 3537#ifdef DEBUG 3538 if ( debug ) { --- 121 unchanged lines hidden (view full) --- 3660static int modem_conn_ignore ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3661static int modem_conn_escape ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3662static int modem_esc_ignore ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3663static int modem_esc_escape ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3664static int modem_esc_data ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3665static int modem_esc_silent ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3666static int modem_esc_disc ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3667 | 3533 3534 DEBUG_TELJJY_PRINTF( "teljjy_conn_silent" ) ; 3535 3536 if ( up->iClockCommandSeq >= 1 3537 && up->iClockCommandSeq < TELJJY_COMMAND_START_SKIP_LOOPBACK ) { 3538 /* Loopback */ 3539#ifdef DEBUG 3540 if ( debug ) { --- 121 unchanged lines hidden (view full) --- 3662static int modem_conn_ignore ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3663static int modem_conn_escape ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3664static int modem_esc_ignore ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3665static int modem_esc_escape ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3666static int modem_esc_data ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3667static int modem_esc_silent ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3668static int modem_esc_disc ( struct peer *, struct refclockproc *, struct jjyunit * ) ; 3669 |
3668static int ( *pModemHandler [ ] [ 5 ] ) ( ) = | 3670static int ( *pModemHandler [ ] [ 5 ] ) ( struct peer *, struct refclockproc *, struct jjyunit * ) = |
3669{ /*STATE_DISCONNECT STATE_INITIALIZE STATE_DAILING STATE_CONNECT STATE_ESCAPE */ 3670/* NULL */ { modem_disc_ignore, modem_init_ignore, modem_dial_ignore , modem_conn_ignore, modem_esc_ignore }, 3671/* INITIALIZE */ { modem_disc_init , modem_init_start , modem_dial_ignore , modem_conn_ignore, modem_esc_ignore }, 3672/* DIALOUT */ { modem_disc_ignore, modem_init_ignore, modem_dial_dialout, modem_conn_ignore, modem_esc_ignore }, 3673/* DISCONNECT */ { modem_disc_ignore, modem_init_disc , modem_dial_escape , modem_conn_escape, modem_esc_escape }, 3674/* RESP: 0: OK */ { modem_disc_ignore, modem_init_resp00, modem_dial_ignore , modem_conn_ignore, modem_esc_data }, 3675/* RESP: 1: CONNECT */ { modem_disc_ignore, modem_init_ignore, modem_dial_connect, modem_conn_ignore, modem_esc_data }, 3676/* RESP: 2: RING */ { modem_disc_ignore, modem_init_ignore, modem_dial_ignore , modem_conn_ignore, modem_esc_data }, --- 311 unchanged lines hidden (view full) --- 3988 3989} 3990 3991/******************************/ 3992static int 3993modem_init_resp00 ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) 3994{ 3995 | 3671{ /*STATE_DISCONNECT STATE_INITIALIZE STATE_DAILING STATE_CONNECT STATE_ESCAPE */ 3672/* NULL */ { modem_disc_ignore, modem_init_ignore, modem_dial_ignore , modem_conn_ignore, modem_esc_ignore }, 3673/* INITIALIZE */ { modem_disc_init , modem_init_start , modem_dial_ignore , modem_conn_ignore, modem_esc_ignore }, 3674/* DIALOUT */ { modem_disc_ignore, modem_init_ignore, modem_dial_dialout, modem_conn_ignore, modem_esc_ignore }, 3675/* DISCONNECT */ { modem_disc_ignore, modem_init_disc , modem_dial_escape , modem_conn_escape, modem_esc_escape }, 3676/* RESP: 0: OK */ { modem_disc_ignore, modem_init_resp00, modem_dial_ignore , modem_conn_ignore, modem_esc_data }, 3677/* RESP: 1: CONNECT */ { modem_disc_ignore, modem_init_ignore, modem_dial_connect, modem_conn_ignore, modem_esc_data }, 3678/* RESP: 2: RING */ { modem_disc_ignore, modem_init_ignore, modem_dial_ignore , modem_conn_ignore, modem_esc_data }, --- 311 unchanged lines hidden (view full) --- 3990 3991} 3992 3993/******************************/ 3994static int 3995modem_init_resp00 ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) 3996{ 3997 |
3996 char *pCmd, cBuf [ 46 ] ; 3997 int iCmdLen ; 3998 int iErrorCorrection, iSpeakerSwitch, iSpeakerVolume ; 3999 int iNextModemState = STAY_MODEM_STATE ; | 3998 const char * pCmd ; 3999 char cBuf [ 46 ] ; 4000 int iCmdLen ; 4001 int iErrorCorrection, iSpeakerSwitch, iSpeakerVolume ; 4002 int iNextModemState = STAY_MODEM_STATE ; |
4000 4001 DEBUG_MODEM_PRINTF( "modem_init_resp00" ) ; 4002 4003 up->iModemCommandSeq++ ; 4004 4005 switch ( up->iModemCommandSeq ) { 4006 4007 case 1 : --- 18 unchanged lines hidden (view full) --- 4026 /* fudge 127.127.40.n flag4 0 */ 4027 iSpeakerVolume = 1 ; 4028 } else { 4029 /* fudge 127.127.40.n flag4 1 */ 4030 iSpeakerVolume = 2 ; 4031 } 4032 4033 pCmd = cBuf ; | 4003 4004 DEBUG_MODEM_PRINTF( "modem_init_resp00" ) ; 4005 4006 up->iModemCommandSeq++ ; 4007 4008 switch ( up->iModemCommandSeq ) { 4009 4010 case 1 : --- 18 unchanged lines hidden (view full) --- 4029 /* fudge 127.127.40.n flag4 0 */ 4030 iSpeakerVolume = 1 ; 4031 } else { 4032 /* fudge 127.127.40.n flag4 1 */ 4033 iSpeakerVolume = 2 ; 4034 } 4035 4036 pCmd = cBuf ; |
4034 snprintf( pCmd, sizeof(cBuf), "ATM%dL%d\r\n", iSpeakerSwitch, iSpeakerVolume ) ; | 4037 snprintf( cBuf, sizeof(cBuf), "ATM%dL%d\r\n", iSpeakerSwitch, iSpeakerVolume ) ; |
4035 break ; 4036 4037 case 3 : 4038 /* &Kn = Flow control 4:XON/XOFF */ 4039 pCmd = "AT&K4\r\n" ; 4040 break ; 4041 4042 case 4 : --- 12 unchanged lines hidden (view full) --- 4055 /* fudge 127.127.40.n flag2 0 */ 4056 iErrorCorrection = 0 ; 4057 } else { 4058 /* fudge 127.127.40.n flag2 1 */ 4059 iErrorCorrection = 3 ; 4060 } 4061 4062 pCmd = cBuf ; | 4038 break ; 4039 4040 case 3 : 4041 /* &Kn = Flow control 4:XON/XOFF */ 4042 pCmd = "AT&K4\r\n" ; 4043 break ; 4044 4045 case 4 : --- 12 unchanged lines hidden (view full) --- 4058 /* fudge 127.127.40.n flag2 0 */ 4059 iErrorCorrection = 0 ; 4060 } else { 4061 /* fudge 127.127.40.n flag2 1 */ 4062 iErrorCorrection = 3 ; 4063 } 4064 4065 pCmd = cBuf ; |
4063 snprintf( pCmd, sizeof(cBuf), "AT\\N%d\r\n", iErrorCorrection ) ; | 4066 snprintf( cBuf, sizeof(cBuf), "AT\\N%d\r\n", iErrorCorrection ) ; |
4064 break ; 4065 4066 case 7 : 4067 /* Hn = Hook 0:Hook-On ( Disconnect ) 1:Hook-Off ( Connect ) */ 4068 pCmd = "ATH1\r\n" ; 4069 break ; 4070 4071 case 8 : --- 174 unchanged lines hidden (view full) --- 4246 4247} 4248 4249/******************************/ 4250static int 4251modem_esc_escape ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) 4252{ 4253 | 4067 break ; 4068 4069 case 7 : 4070 /* Hn = Hook 0:Hook-On ( Disconnect ) 1:Hook-Off ( Connect ) */ 4071 pCmd = "ATH1\r\n" ; 4072 break ; 4073 4074 case 8 : --- 174 unchanged lines hidden (view full) --- 4249 4250} 4251 4252/******************************/ 4253static int 4254modem_esc_escape ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) 4255{ 4256 |
4254 char *pCmd ; 4255 int iCmdLen ; | 4257 const char * pCmd ; 4258 int iCmdLen ; |
4256 4257 DEBUG_MODEM_PRINTF( "modem_esc_escape" ) ; 4258 4259 /* Escape command ( Go to command mode ) */ 4260 pCmd = "+++" ; 4261 4262 /* Send command */ 4263 iCmdLen = strlen( pCmd ) ; --- 48 unchanged lines hidden (view full) --- 4312 return modem_esc_disc( peer, pp, up ) ; 4313 4314} 4315/******************************/ 4316static int 4317modem_esc_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) 4318{ 4319 | 4259 4260 DEBUG_MODEM_PRINTF( "modem_esc_escape" ) ; 4261 4262 /* Escape command ( Go to command mode ) */ 4263 pCmd = "+++" ; 4264 4265 /* Send command */ 4266 iCmdLen = strlen( pCmd ) ; --- 48 unchanged lines hidden (view full) --- 4315 return modem_esc_disc( peer, pp, up ) ; 4316 4317} 4318/******************************/ 4319static int 4320modem_esc_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up ) 4321{ 4322 |
4320 char *pCmd ; 4321 int iCmdLen ; | 4323 const char * pCmd ; 4324 int iCmdLen ; |
4322 4323 DEBUG_MODEM_PRINTF( "modem_esc_disc" ) ; 4324 4325 /* Disconnect */ 4326 pCmd = "ATH0\r\n" ; 4327 4328 /* Send command */ 4329 iCmdLen = strlen( pCmd ) ; --- 14 unchanged lines hidden (view full) --- 4344/*## ##*/ 4345/*################################################################################################*/ 4346/*################################################################################################*/ 4347 4348static void 4349jjy_write_clockstats ( struct peer *peer, int iMark, const char *pData ) 4350{ 4351 | 4325 4326 DEBUG_MODEM_PRINTF( "modem_esc_disc" ) ; 4327 4328 /* Disconnect */ 4329 pCmd = "ATH0\r\n" ; 4330 4331 /* Send command */ 4332 iCmdLen = strlen( pCmd ) ; --- 14 unchanged lines hidden (view full) --- 4347/*## ##*/ 4348/*################################################################################################*/ 4349/*################################################################################################*/ 4350 4351static void 4352jjy_write_clockstats ( struct peer *peer, int iMark, const char *pData ) 4353{ 4354 |
4352 char sLog [ 100 ] ; 4353 char *pMark ; 4354 int iMarkLen, iDataLen ; | 4355 char sLog [ 100 ] ; 4356 const char * pMark ; 4357 int iMarkLen, iDataLen ; |
4355 4356 switch ( iMark ) { 4357 case JJY_CLOCKSTATS_MARK_JJY : 4358 pMark = "JJY " ; 4359 break ; 4360 case JJY_CLOCKSTATS_MARK_SEND : 4361 pMark = "--> " ; 4362 break ; --- 95 unchanged lines hidden --- | 4358 4359 switch ( iMark ) { 4360 case JJY_CLOCKSTATS_MARK_JJY : 4361 pMark = "JJY " ; 4362 break ; 4363 case JJY_CLOCKSTATS_MARK_SEND : 4364 pMark = "--> " ; 4365 break ; --- 95 unchanged lines hidden --- |