void main(){ int fd; char buffer2[66]; char buffer3[]="massage number X\n"; char buffer[]={1,0,0,0,0,6,7,8,9,0,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,10,10}; unsigned short i=48,j=0, m_len=0, flag=0, len=0, len2=0; int payload = 64, header_size =2; printf("starting.....(termios)\n"); init_file(src); fd = init_modem(); len = sizeof(buffer); while(1){ sleep(5); buffer[len - 3] = i; printf("sending massage of length %d, msg is:", len); showMsg(buffer, len); printf("\n"); sendToModem(fd, buffer, len); i++; if(i==58) i=48; }//while(1) }//main
void main(){ char buffer2[66]; char buffer3[]="massage number X\n"; char buffer[]={2,0,3,4,5,6,7,8,9,0,11,33,34,35,36,37,38,39,40,41,42,43,44,45,46}; // unsigned short i=48,j=0, m_len=0, flag=0, len=0, X=0; int payload = 64, header_size =2; printf("starting.....\n"); //init_file(src); init_modem(); sleep(1); //send_garbage(30); //sleep(1); len = sizeof(buffer); while(1){ //delay(10); sleep(3); buffer[len - 3] = i; printf("sending massage of length %d, msg is:", len); showMsg(buffer, len); printf("\n"); sendToModem(buffer, len); i++; if(i==58) i=48; //X = usleep(1000); printf("pass usleep\n"); }//while(1) }//main
unsigned char init_fm(void) { P3DDR |= (1 << 4); // FMSTB : OUT P3DDR |= (1 << 5); // FMDAT : OUT P3DDR |= (1 << 6); // FMCLK : OUT P3DDR |= (1 << 7); // FMPTT : OUT P1DDR |= (1 << 0); //FMCWSW : OUT P1DDR |= (1 << 1); //FMDTSW : OUT init_modem(); // モデムの初期化 fmptt_off(); return 1; }
void main(){ unsigned char buffer[100]; unsigned char temp_buffer[100]; char msg[100]; int m_len; unsigned long error_counter=0; init_file(src); init_modem(); printf("starting receiver\n"); //Test Code /*int j=0,jj=1; for(j;j!=10,jj==1;j++){ if(j==80) printf("Fail"); if(jj=1) printf("Success"); } exit(0);*/ //End of Test code while(1){ m_len = 0; if( (m_len = get_modem_frame(buffer)) > 0){ if(m_len < 3 ) { showMsg(buffer, m_len); error_counter++; }//if(m_len<3) if(m_len>3){ //printf("m_len is:%d\n", m_len); showMsg(buffer, m_len); //printf("error till now:%ld\n", error_counter); }//if(m_len>3) }//if(get_frame>0) if(m_len<0) { printf("m_len is:%d, bad!!", m_len); } }//while(1) }//main
int main(int argc, char *argv[]) { if (argc < 3) { printf("usage: %s PAGE DUMPFILE\n", argv[0]); printf("\tPAGE\t\t -1 for all memory dump, 0-63 for single page dump\n"); printf("\tDUMPFILE\tfile where write memory dump\n"); return 1; } int fd = init_port("/dev/ttyS0"); int res = 0; res = init_modem(fd); if (res != 0) return res; res = get_modem_memory(fd, argv[2], atoi(argv[1])); if (res != 0) return res; close(fd); return 0; }
static void elsa_test(struct IsdnCardState *cs) { if ((cs->subtyp == ELSA_PCMCIA) || (cs->subtyp == ELSA_PCMCIA_IPAC) || (cs->subtyp == ELSA_QS1000PCI)) { return; } if (cs->subtyp != ELSA_QS3000PCI) { cs->hw.elsa.counter = 0; cs->hw.elsa.ctrl_reg |= ELSA_ENA_TIMER_INT; cs->hw.elsa.status |= ELSA_TIMER_AKTIV; byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg); byteout(cs->hw.elsa.timer, 0); set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout((110*HZ)/1000); cs->hw.elsa.ctrl_reg &= ~ELSA_ENA_TIMER_INT; byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg); cs->hw.elsa.status &= ~ELSA_TIMER_AKTIV; printk(KERN_INFO "Elsa: %d timer tics in 110 msek\n", cs->hw.elsa.counter); if ((cs->hw.elsa.counter > 10) && (cs->hw.elsa.counter < 16)) { printk(KERN_INFO "Elsa: timer and irq OK\n"); } else { printk(KERN_WARNING "Elsa: timer tic problem (%d/12) maybe an IRQ(%d) conflict\n", cs->hw.elsa.counter, cs->irq); } } #if ARCOFI_USE if (check_arcofi(cs)) { init_modem(cs); } #endif elsa_led_handler(cs); }
void ppp_input_task(intptr_t exinf) { T_NET_BUF *input; T_PPP_PROTENT *proto; ID tskid; int_t ix; /* ポートを初期設定する */ syscall(serial_opn_por(HDLC_PORTID)); syscall(serial_ctl_por(HDLC_PORTID, IOCTL_FCSND | IOCTL_FCRCV)); get_tid(&tskid); #ifdef PPP_CFG_MODEM init_modem(); syslog(LOG_NOTICE, "[PPP INPUT:%d] started with modem on port %d.", tskid, HDLC_PORTID); #else /* of #ifdef PPP_CFG_MODEM */ syslog(LOG_NOTICE, "[PPP INPUT:%d] started on port %d.", tskid, HDLC_PORTID); #endif /* of #ifdef PPP_CFG_MODEM */ /* ネットワークタイマタスクを起動する */ syscall(act_tsk(NET_TIMER_TASK)); /* 上位プロトコルを初期化する */ for (ix = 0; (proto = protocols[ix]) != NULL; ix ++) if (proto->init != NULL) (*proto->init)(); lcp_lowerup(); lcp_open(PPP_OPEN_PASSIVE); /* PPP 出力タスクを起動する */ syscall(act_tsk(PPP_OUTPUT_TASK)); while (true) { if (tget_net_buf(&input, IF_PDU_SIZE, TMO_PPP_GET_NET_BUF) == E_OK) { while (HDLC_read(input, IF_PDU_SIZE) != E_OK) ; if (input->len > 0) { #ifdef PPP_IDLE_TIMEOUT wai_sem(SEM_IDLE_TIMEOUT); if (idle && ntohs(*GET_PPP_HDR(input)) != PPP_LCP) { untimeout((FP)idle_timeout, NULL); idle = false; } sig_sem(SEM_IDLE_TIMEOUT); #endif /* of #ifdef PPP_IDLE_TIMEOUT */ parse_input(input); } else syscall(rel_net_buf(input)); #ifdef PPP_IDLE_TIMEOUT wai_sem(SEM_IDLE_TIMEOUT); if (!idle && ppp_phase == PPP_PHASE_NETWORK) { timeout((FP)idle_timeout, NULL, PPP_IDLE_TIMEOUT); idle = true; } else if (idle && ppp_phase != PPP_PHASE_NETWORK) { untimeout((FP)idle_timeout, NULL); idle = false; } sig_sem(SEM_IDLE_TIMEOUT); #endif /* of #ifdef PPP_IDLE_TIMEOUT */ } else { HDLC_dummy_read(); NET_COUNT_PPP(net_count_ppp.in_err_packets, 1); NET_COUNT_PPP(net_count_ppp_no_bufs, 1); } } }
static int Elsa_card_msg(struct IsdnCardState *cs, int mt, void *arg) { int ret = 0; u_long flags; switch (mt) { case CARD_RESET: spin_lock_irqsave(&cs->lock, flags); reset_elsa(cs); spin_unlock_irqrestore(&cs->lock, flags); return(0); case CARD_RELEASE: release_io_elsa(cs); return(0); case CARD_INIT: spin_lock_irqsave(&cs->lock, flags); cs->debug |= L1_DEB_IPAC; reset_elsa(cs); inithscxisac(cs, 1); if ((cs->subtyp == ELSA_QS1000) || (cs->subtyp == ELSA_QS3000)) { byteout(cs->hw.elsa.timer, 0); } if (cs->hw.elsa.trig) byteout(cs->hw.elsa.trig, 0xff); inithscxisac(cs, 2); spin_unlock_irqrestore(&cs->lock, flags); return(0); case CARD_TEST: if ((cs->subtyp == ELSA_PCMCIA) || (cs->subtyp == ELSA_PCMCIA_IPAC) || (cs->subtyp == ELSA_QS1000PCI)) { return(0); } else if (cs->subtyp == ELSA_QS3000PCI) { ret = 0; } else { spin_lock_irqsave(&cs->lock, flags); cs->hw.elsa.counter = 0; cs->hw.elsa.ctrl_reg |= ELSA_ENA_TIMER_INT; cs->hw.elsa.status |= ELSA_TIMER_AKTIV; byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg); byteout(cs->hw.elsa.timer, 0); spin_unlock_irqrestore(&cs->lock, flags); msleep(110); spin_lock_irqsave(&cs->lock, flags); cs->hw.elsa.ctrl_reg &= ~ELSA_ENA_TIMER_INT; byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg); cs->hw.elsa.status &= ~ELSA_TIMER_AKTIV; spin_unlock_irqrestore(&cs->lock, flags); printk(KERN_INFO "Elsa: %d timer tics in 110 msek\n", cs->hw.elsa.counter); if ((cs->hw.elsa.counter > 10) && (cs->hw.elsa.counter < 16)) { printk(KERN_INFO "Elsa: timer and irq OK\n"); ret = 0; } else { printk(KERN_WARNING "Elsa: timer tic problem (%d/12) maybe an IRQ(%d) conflict\n", cs->hw.elsa.counter, cs->irq); ret = 1; } } #if ARCOFI_USE if (check_arcofi(cs)) { init_modem(cs); } #endif elsa_led_handler(cs); return(ret); case (MDL_REMOVE | REQUEST): cs->hw.elsa.status &= 0; break; case (MDL_ASSIGN | REQUEST): cs->hw.elsa.status |= ELSA_ASSIGN; break; case MDL_INFO_SETUP: if ((long) arg) cs->hw.elsa.status |= 0x0200; else cs->hw.elsa.status |= 0x0100; break; case MDL_INFO_CONN: if ((long) arg) cs->hw.elsa.status |= 0x2000; else cs->hw.elsa.status |= 0x1000; break; case MDL_INFO_REL: if ((long) arg) { cs->hw.elsa.status &= ~0x2000; cs->hw.elsa.status &= ~0x0200; } else { cs->hw.elsa.status &= ~0x1000; cs->hw.elsa.status &= ~0x0100; } break; #if ARCOFI_USE case CARD_AUX_IND: if (cs->hw.elsa.MFlag) { int len; u_char *msg; if (!arg) return(0); msg = arg; len = *msg; msg++; modem_write_cmd(cs, msg, len); } break; #endif } if (cs->typ == ISDN_CTYPE_ELSA) { int pwr = bytein(cs->hw.elsa.ale); if (pwr & 0x08) cs->hw.elsa.status |= ELSA_BAD_PWR; else cs->hw.elsa.status &= ~ELSA_BAD_PWR; } elsa_led_handler(cs); return(ret); }
void get_serial_modem(hd_data_t *hd_data) { hd_t *hd; int i, j, fd; unsigned modem_info, baud; char *command; ser_device_t *sm; int chk_usb = hd_probe_feature(hd_data, pr_modem_usb); /* serial modems & usb modems */ for(hd = hd_data->hd; hd; hd = hd->next) { if( ( ( hd->base_class.id == bc_comm && hd->sub_class.id == sc_com_ser && !hd->tag.ser_skip && hd->tag.ser_device != 2 && /* cf. serial.c */ !has_something_attached(hd_data, hd) ) || ( chk_usb && hd->bus.id == bus_usb && hd->base_class.id == bc_modem ) ) && hd->unix_dev_name ) { if(dev_name_duplicate(hd_data, hd->unix_dev_name)) continue; if((fd = open(hd->unix_dev_name, O_RDWR | O_NONBLOCK)) >= 0) { sm = add_ser_modem_entry(&hd_data->ser_modem, new_mem(sizeof *sm)); sm->dev_name = new_str(hd->unix_dev_name); sm->fd = fd; sm->hd_idx = hd->idx; sm->do_io = 1; init_modem(sm); } } } if(!hd_data->ser_modem) return; PROGRESS(2, 0, "init"); usleep(300000); /* PnP protocol; 200ms seems to be too fast */ for(sm = hd_data->ser_modem; sm; sm = sm->next) { modem_info = TIOCM_DTR | TIOCM_RTS; ioctl(sm->fd, TIOCMBIS, &modem_info); ioctl(sm->fd, TIOCMGET, &modem_info); if(!(modem_info & (TIOCM_DSR | TIOCM_CD))) { sm->do_io = 0; } } /* just a quick test if we get a response to an AT command */ for(i = 0; i < 4; i++) { PROGRESS(3, i + 1, "at test"); for(sm = hd_data->ser_modem; sm; sm = sm->next) { if(!sm->is_modem) set_modem_speed(sm, i == 0 ? 115200 : i == 1 ? 38400 : i == 2 ? 9600 : 1200); } at_cmd(hd_data, "AT\r", 1, 1); for(sm = hd_data->ser_modem; sm; sm = sm->next) { if(strstr(sm->buf, "OK") || strstr(sm->buf, "0")) { sm->is_modem = 1; sm->do_io = 0; } sm->buf_len = 0; /* clear buffer */ } } for(sm = hd_data->ser_modem; sm; sm = sm->next) { if((sm->do_io = sm->is_modem)) { sm->max_baud = sm->cur_baud; } } /* check for init string */ PROGRESS(4, 0, "init string"); command = NULL; for(i = 0; (unsigned) i < MAX_INIT_STRING; i++) { str_printf(&command, 0, "AT %s\r", init_strings[i]); at_cmd(hd_data, command, 1, 1); for(sm = hd_data->ser_modem; sm; sm = sm->next) { if(strstr(sm->buf, "OK") || strstr(sm->buf, "0")) { str_printf(&sm->init_string2, -1, "%s %s", sm->init_string2 ? "" : "AT", init_strings[i] ); } } } command = free_mem(command); for(sm = hd_data->ser_modem; sm; sm = sm->next) if(sm->is_modem) str_printf(&sm->init_string1, -1, "ATZ"); { int cmds[] = { 1, 3, 4, 5, 6 }; char at[10]; int i, j, ModemsCount = 0; str_list_t **responces = NULL; for(sm = hd_data->ser_modem; sm; sm = sm->next) if(sm->is_modem) ModemsCount++; responces = new_mem(ModemsCount * sizeof *responces); at_cmd(hd_data, "ATI\r", 0, 1); for(j = 0, sm = hd_data->ser_modem; sm; sm = sm->next) { if(sm->is_modem) responces[j++] = str_list_dup(sm->at_resp); } for(i = 0; (unsigned) i < sizeof cmds / sizeof *cmds; i++) { int atx = cmds[i]; sprintf(at, "ATI%d\r", atx); at_cmd(hd_data, at, 0, 1); for(j = 0, sm = hd_data->ser_modem; sm; sm = sm->next) { if(sm->is_modem) { if(atx == 1 && check_for_responce(responces[j], "Hagenuk", 7) && (check_for_responce(sm->at_resp, "Speed Dragon", 12) || check_for_responce(sm->at_resp, "Power Dragon", 12))) { free_mem(sm->init_string1); free_mem(sm->init_string2); sm->init_string1 = new_str("AT&F"); sm->init_string2 = new_str("ATB8"); } if(atx == 3 && check_for_responce(responces[j], "346900", 6) && check_for_responce(sm->at_resp, "3Com U.S. Robotics ISDN", 23)) { free_mem(sm->init_string1); free_mem(sm->init_string2); sm->init_string1 = new_str("AT&F"); sm->init_string2 = new_str("AT*PPP=1"); } if(atx == 4 && check_for_responce(responces[j], "SP ISDN", 7) && check_for_responce(sm->at_resp, "Sportster ISDN TA", 17)) { free_mem(sm->init_string1); free_mem(sm->init_string2); sm->init_string1 = new_str("AT&F"); sm->init_string2 = new_str("ATB3"); } if(atx == 6 && check_for_responce(responces[j], "644", 3) && check_for_responce(sm->at_resp, "ELSA MicroLink ISDN", 19)) { free_mem(sm->init_string1); free_mem(sm->init_string2); sm->init_string1 = new_str("AT&F"); sm->init_string2 = new_str("AT$IBP=HDLCP"); free_mem(sm->pppd_option); sm->pppd_option = new_str("default-asyncmap"); } if(atx == 6 && check_for_responce(responces[j], "643", 3) && check_for_responce(sm->at_resp, "MicroLink ISDN/TLV.34", 21)) { free_mem(sm->init_string1); free_mem(sm->init_string2); sm->init_string1 = new_str("AT&F"); sm->init_string2 = new_str("AT\\N10%P1"); } if(atx == 5 && check_for_responce(responces[j], "ISDN TA", 6) && check_for_responce(sm->at_resp, "ISDN TA;ASU", 4)) { free_mem(sm->vend); sm->vend = new_str("ASUS"); free_mem(sm->user_name); sm->user_name = new_str("ISDNLink TA"); free_mem(sm->init_string1); free_mem(sm->init_string2); sm->init_string1 = new_str("AT&F"); sm->init_string2 = new_str("ATB40"); } if(atx==3 && check_for_responce(responces[j], "128000", 6) && check_for_responce(sm->at_resp, "Lasat Speed", 11)) { free_mem(sm->init_string1); free_mem(sm->init_string2); sm->init_string1 = new_str("AT&F"); sm->init_string2 = new_str("AT\\P1&B2X3"); } if(atx == 1 && (check_for_responce(responces[j], "28642", 5) || check_for_responce(responces[j], "1281", 4) || check_for_responce(responces[j], "1282", 4) || check_for_responce(responces[j], "1283", 4) || check_for_responce(responces[j], "1291", 4) || check_for_responce(responces[j], "1292", 4) || check_for_responce(responces[j], "1293", 4)) && (check_for_responce(sm->at_resp, "Elite 2864I", 11) || check_for_responce(sm->at_resp, "ZyXEL omni", 10))) { free_mem(sm->init_string1); free_mem(sm->init_string2); sm->init_string1 = new_str("AT&F"); sm->init_string2 = new_str("AT&O2B40"); } j++; } } } for(i = 0; i < ModemsCount; i++) free_str_list(responces[i]); free_mem(responces); } /* now, go for the maximum speed... */ PROGRESS(5, 0, "speed"); for(i = MAX_SPEED - 1; i >= 0; i--) { baud = speeds[i].baud; for(j = 0, sm = hd_data->ser_modem; sm; sm = sm->next) { if(sm->is_modem) { if(baud > sm->max_baud) { sm->do_io = set_modem_speed(sm, baud) ? 0 : 1; if(sm->do_io) j++; } } } /* no modems */ if(!j) continue; at_cmd(hd_data, "AT\r", 1, 0); for(sm = hd_data->ser_modem; sm; sm = sm->next) { if(strstr(sm->buf, "OK") || strstr(sm->buf, "0")) { sm->max_baud = sm->cur_baud; } else { sm->do_io = 0; } sm->buf_len = 0; /* clear buffer */ } } /* now, fix it all up... */ for(sm = hd_data->ser_modem; sm; sm = sm->next) { if(sm->is_modem) { set_modem_speed(sm, sm->max_baud); sm->do_io = 1; } } #if 0 /* just for testing */ if((hd_data->debug & HD_DEB_MODEM)) { int i; int cmds[] = { 0, 1, 2, 3, 6 }; char at[10]; PROGRESS(8, 0, "testing"); at_cmd(hd_data, "ATI\r", 0, 1); for(i = 0; (unsigned) i < sizeof cmds / sizeof *cmds; i++) { sprintf(at, "ATI%d\r", cmds[i]); at_cmd(hd_data, at, 0, 1); } at_cmd(hd_data, "AT\r", 0, 1); } #endif PROGRESS(5, 0, "pnp id"); at_cmd(hd_data, "ATI9\r", 1, 1); for(sm = hd_data->ser_modem; sm; sm = sm->next) { if(sm->is_modem) { chk4id(sm); if(!sm->user_name) guess_modem_name(hd_data, sm); } /* reset serial lines */ tcflush(sm->fd, TCIOFLUSH); tcsetattr(sm->fd, TCSAFLUSH, &sm->tio); close(sm->fd); } }