emobile EM-ONE
久々のエントリです。
EM-ONEを買いました。
僕はMacBookProを持ち歩いているので、EM-ONEもMacで使いたい。
そもそもモバイル属性があんまりないので、モデムにならなきゃ嫌だと。
Macは一応EM-ONEの公式サポートに入ってないのですけど
モデムくらいなんとかなるだろうということで買ってきました。
http://fomausbosx.sourceforge.jp/ こちらのUSBドライバに含まれるモデムスクリプトを改造して
BTで使えるようにしました。
僕はMac使うようになって日が浅いのでありがたいことです。
ちなみに、データレートの設定とか、本当に正しいのかは疑問の余地があります。
何か不利益が発生しても僕のせいにしないでね。
本スクリプトは野良のものです。ご自身の責任のもと楽しんでいただければと思います。
/Libraty/Modem Scripts/ 以下に、次のテキストファイルを適当なファイル名でぶち込んでください。
Macをリブートするとそのファイル名が、モデムの一覧にそのまま現れますので
モデムっぽい名前を付けたほうがいいでしょう。
USBで使いたい人は http://sourceforge.jp/projects/emoneusbmac/ こちらも参考にどうぞ。
! ----------------------------------------------------------------------
! EM-ONE GlobeTrotter Module 3G+ Modem Script (fake)
!
! Based on FOMA USB for Mac driver (http://fomausbosx.sourceforge.jp/),
! thank you!
! ----------------------------------------------------------------------
@ORIGINATE
@ANSWER
note "EM-ONE GT3G+ Modem Script (fake) activated" 3
! serreset 230400, 0, 8, 1
! serreset 460800, 0, 8, 1
! serreset 576000, 0, 8, 1
! serreset 678500, 0, 8, 1
serreset 921600, 0, 8, 1
hsreset 0 0 0 0 0 0
settries 0
!
! Get the modem's attention
!
matchclr
matchstr 1 3 "OK\13\10"
! write "AT\13"
write "AT&F\13"
matchread 30
jump 101
!
! Setup the modem for the following:
! Reset to factory defaults (&F)
! Echo off (E0)
! Return result codes (Q0)
! Verbose responses (V1)
! Tone detection on (X4)
! DCD/DTR settings (&C1&D2)
! Detailed result codes (\V1)
! Flow control (+IFC=2,2)
! Turn off answering (S0=0)
!
@LABEL 3
matchclr
matchstr 1 13 "OK\13\10"
matchstr 2 101 "ERROR\13\10"
write "AT&FE0V1&D2&C1S0=0\13"
! remote peerの状況に依りそうだが、5秒は長い
! pause 5 -> 2
pause 2
matchread 90
inctries
iftries 3 101
!
! Reset the Modem on setup failure
!
DTRClear
pause 2
DTRSet
flush
! pause 90 -> 5 リダイアル規制は不要
pause 2
jump 3
!
! Originating a call.
!
@LABEL 13
ifANSWER 32
!
! If varString6 is set to 1, set up the phone to dial without
! confirmation of dialtone detection.
!
ifstr 6 19 "0"
matchclr
matchstr 1 19 "OK\13\10"
write "ATX1\13"
matchread 30
jump 101
!
! Dial
!
@LABEL 19
! Display the full dialstring contained in Varstring 1
note "Dialing ^1" 3
!
! Varstrings 7, 8 and 9, contain dialstring fragments
! Long phone numbers may need to be split into smaller groups
! for the modem to use
!
! Varstring 8 == blank (dialstring in varstring 7)
! Varstring 9 == blank (dialstring in varstrings 7 & 8)
! Otherwise (dialstring in varstrings 7, 8 & 9)
flush
ifstr 8 21 " "
ifstr 9 20 " "
!
! Write dialstring in varstrings 7, 8 & 9
!
write "ATD^7^8^9\13"
jump 32
!
! Write dialstring in varstrings 7 & 8
!
@LABEL 20
write "ATD^7^8\13"
jump 32
!
!
! Write dialstring in varstring 7
!
@LABEL 21
write "ATD^7\13"
!
! Parse the modem's response.
!
@LABEL 32
matchclr
matchstr 1 33 "CONNECT "
matchstr 2 80 "CONNECT\13\10"
matchstr 3 88 "RING\13\10"
matchstr 4 105 "NO CARRIER"
matchstr 5 105 "ERROR\13\10"
matchstr 6 103 "NO DIALTONE\13\10"
matchstr 7 107 "BUSY\13\10"
matchstr 8 109 "NO ANSWER\13\10"
matchstr 9 105 "RESTRICTION\13\10"
matchstr 10 111 "DELAYED\13\10"
matchread 700
ifANSWER 32
jump 101
!
! Determine the connection rate.
@LABEL 33
matchclr
matchstr 1 39 "2400"
matchstr 2 40 "4800"
matchstr 3 41 "9600"
matchstr 4 42 "14400"
matchstr 5 43 "19200"
matchstr 6 44 "1800000"
matchstr 7 45 "3600000"
matchstr 8 46 "7200000"
matchread 30
jump 80
!
@LABEL 39
note "Communicating at 2400 bps." 2
CommunicatingAt 2400
jump 81
!
@LABEL 40
note "Communicating at 4800 bps." 2
CommunicatingAt 4800
jump 81
!
@LABEL 41
note "Communicating at 9600 bps." 2
CommunicatingAt 9600
jump 81
!
@LABEL 42
note "Communicating at 14400 bps." 2
CommunicatingAt 14400
jump 81
!
@LABEL 43
note "Communicating at 19200 bps." 2
CommunicatingAt 19200
jump 81
!
@LABEL 44
note "Communicating at 1800000 bps." 2
note "Communicating at 1800000 bps." 3
CommunicatingAt 1800000
jump 81
@LABEL 45
note "Communicating at 3600000 bps." 2
note "Communicating at 3600000 bps." 3
CommunicatingAt 3600000
jump 81
@LABEL 46
note "Communicating at 7200000 bps." 2
note "Communicating at 7200000 bps." 3
CommunicatingAt 7200000
jump 81
!
@LABEL 47
note "Communicating at 64 kbps." 2
CommunicatingAt 64000
jump 81
!
@LABEL 48
note "Packet communication at 384 kbps down/64 kbps up." 2
CommunicatingAt 384000
jump 81
!
@LABEL 80
note "Communicating at an unknown rate." 2
note "Communicating at an unknown rate." 3
jump 81
! -- Normal exit after "CONNECT" --
!
! This modem has been setup to do CTS handshaking,
! and we assume that a CTS handshaking cable is being used.
@LABEL 81
! Turn on RTS/CTS handshaking.
HSReset 0 1 0 0 0 0
ifANSWER 87
!pause 30
pause 2
@LABEL 87
exit 0
! ----------------------------------------------------------------------
!
! Answer calls
!
! A RING result from the modem when in ANSWER mode claims the
! serial port and answers the phone.
!
@LABEL 88
ifORIGINATE 32
userhook 1
note "Answering phone..." 2
write "ATA\13"
jump 32
! ----------------------------------------------------------------------
!
! Hang up and reset modem
!
@HANGUP
@LABEL 90
settries 0
HSReset 0 0 0 0 0 0
!
! Escape from data to command mode
!
@LABEL 92
flush
pause 1
write "+++"
pause 1
matchclr
matchstr 1 96 "OK\13\10"
matchread 30
!
! Force a hangup
!
@LABEL 94
! IO-DATA USB-CFADPのCCLではflushなし
! HANGUP時に無限待ちするのと関係ある?
! flush
matchclr
matchstr 1 98 "NO CARRIER\13\10"
matchstr 2 98 "OK\13\10"
matchstr 3 98 "ERROR\13\10"
matchstr 4 98 "0\13\10"
! write "ATH\13"
write "ATH E1\13"
matchread 150
!
! Try to get control of the modem by toggling DTR
!
DTRClear
pause 5
DTRSet
flush
!
! Try the hangup sequence three times otherwise declare and error
!
inctries
! retry 3 -> 1
iftries 1 101
jump 92
!
! Pause between data and command mode
!
@LABEL 96
! pause 50 -> 10 長過ぎる
pause 10
jump 94
!
! Recall the factory settings
!
@LABEL 98
! pause 15 -> 5
pause 5
matchclr
matchstr 1 99 "OK\13\10"
write "AT&F\13"
matchread 30
jump 101
@LABEL 99
exit 0
! ----------------------------------------------------------------------
!
! Error messages
!
!
! Modem Not Responding
!
@LABEL 101
write "AT&F\13"
pause 10
exit -6019
!
! No Dialtone
!
@LABEL 103
matchstr 1 104 "OK\13\10"
write "AT&F\13"
matchread 30
@LABEL 104
exit -6020
!
! No Carrier or Error
!
@LABEL 105
matchstr 1 106 "OK\13\10"
write "AT&F\13"
matchread 30
@LABEL 106
exit -6021
!
! Busy or Delayed
!
@LABEL 107
matchstr 1 108 "OK\13\10"
write "AT&F\13"
matchread 30
@LABEL 108
exit -6022
!
! No Answer
!
@LABEL 109
matchstr 1 110 "OK\13\10"
write "AT&F\13"
matchread 30
@LABEL 110
exit -6023
!
! Delayed
!
@LABEL 111
note "DELAYED"
pause 20
exit -6008
! ---------------------------- ここまで -----------------------------
トラックバック張れないのかな、vox
http://blog.seesaa.jp/tb/37454534
==================
2007/4/10 追記
==================
あちこちに紹介されるにあたって多少まともにしました。
変更点は、
1. 設定を強めた
2. 接続速度が表示されるようになった
(ただしサーバーのリプライが3600000の時のみ・・・。マッチ文字列ってどうやって取るんだろう?)
3. デバッグ向けに多少ログを吐くようにした
4. HANGUPの時のATコマンドを多少弱めた
1について。
別に本物のシリアルポートじゃなし、Macに付いてるモデムを操作するんじゃなし、ということで
比較的いい加減に設定してきましたがちゃんと効いているようです。
あまり無茶なボーレートを設定するとカーネルに跳ねられるかと思ったのですが、
結構いけるようなので強めてみました。
BTで使うときにはあまり意味がないように見えるのですが、USB接続の際にはかなり効きます。
2はかなりいい加減な実装なので、常に「3600000bpsで接続」と表示され、却って苛立ちを煽る結果に
なるかも知れません。
PPPのピアから、一体どんな設定が帰ってくるのか不明でもありますし。
部分一致文字列を得る方法がわかればいいんですが、よく解りませんでして申し訳ないです。
4.はHANGUPの時にHコマンドを送っていたのですが、ただのモデムじゃないので少しビビッてしまい
&Fくらいにしておくことにしました。
(結局、Windows版と同じ設定にしてあります)
たまにEMONE側から切断されると、どうにもならなくなることがあるのですが、これは少し様子見です。
==================
2007/4/12 追記
==================
・Macがモデムの応答を待ち続けるバグの修正
・タイムアウト値の調整
モデム側の都合で切断されたとき、Mac側でバッファをflushしようとして待ち続けるバグが直りました。
これで切れまくってもストレスが低減されると思います。
以前のバージョンを使われている方がいらっしゃいましたら、更新をお勧めします。
EM-ONEのUSB接続では動作を確認しております。
Windows版と比べるとパフォーマンスが出ないように見えます。(BTではあまり違いなし)
多分USBドライバのバスプローブに秘密があるのでしょう。
(Com系のクラスだとISOかと思いきや、バルク転送が使われていたりする?)
CFスロットやPCI−eのe-mobileのモデムですが、動作確認された方いらっしゃいましたら
コメント頂けるとありがたいです。
Comments
でしたら光栄です。
使わせていただいております。
ご指摘の通り、IO-DATAのスクリプトで動作を確認しております。
僕が購入した当初、良く適合するスクリプトがわからなかったので、
純正Windows用スクリプトの設定を引っこ抜いてきて使ったのがこれということです。
僕のMacBookProにはPCカードがないので助かります。
(IOの変換アダプタを使ってCF版を試してみたのですけど、だめでした)
ということは、MacOS標準のPCカードCOMドライバはそのまま使えるということですね。
(モデムスクリプトさえ置き換えれば)