mirror of
https://github.com/D-Modem/app.git
synced 2026-11-28 17:38:05 -08:00
Agere USB 2.0 soft modems as the line (D-Modem-RE a30aa39)
D-Modem-RE's third USB line, usb_agere.cpp (047E:2892, 047E:2828), in the app's native build beside the SmartUSB56's and the pico-serial Line's. Its ROM patches (D-Modem-RE's firmware/agere: Agere's, under Agere's licence, with its LICENSE and NOTICE.md) are copied into the APK's assets at build time (agereFirmware) and installed in the app's files when an Agere modem is the line, DMODEM_AGERE_FIRMWARE pointing D-Modem-RE at them. UsbModems knows the two IDs, and runs it at 8000 Hz (the others at 9600); Android offers the app when one is plugged in; the line's settings say so. native-test: agere_host on D-Modem-RE's fake Agere modems (fake_agere.cpp), their patches the tests' own in a firmware directory: usb_line_test.py's agere run, ATI3, caller ID, CONNECT 33600 both ways, data, hang up, unplugged. AgereFirmwareTest: the patches installed as shipped (D-Modem-RE's SHA-256 sums), the licence beside them. D-Modem-RE a30aa39 too: V.cvm's MPs through AMR-WB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
This commit is contained in:
13 files changed
+174
-27
No files matched your search
@@ -95,7 +95,13 @@ carries the modem's sound (D-Modem-RE's `usb_line.cpp`, as
|
||||
with caller ID, its ST7554 or ST75951 DAA), or a
|
||||
[pico-serial](https://github.com/Neo-Desktop/pico-serial) Line stick
|
||||
(1209:0002, a Si3056 DAA: caller ID on hook, and the country's line
|
||||
settings in its registers). The phone runs the modem; plugged into it
|
||||
settings in its registers), or an Agere USB 2.0 soft modem (047E:2892,
|
||||
047E:2828: 8000 Hz, caller ID; its ROM patched as it starts with
|
||||
Agere's bulk patch). Agere's ROM patches come from D-Modem-RE's
|
||||
`firmware/agere` into the APK's assets (`app/build.gradle.kts`'s
|
||||
agereFirmware) and are installed in the app's files for D-Modem-RE
|
||||
(`DMODEM_AGERE_FIRMWARE`); they are Agere's, under Agere's licence, not
|
||||
the AGPL (its LICENSE and NOTICE.md go with them). The phone runs the modem; plugged into it
|
||||
(USB OTG) the stick is its line, with no SIP account or network. Settings,
|
||||
Line, "A phone line, through a USB modem"; Android asks once whether
|
||||
D-Modem may use it, and offers the app when one is plugged in.
|
||||
@@ -107,7 +113,7 @@ allowed and gives its descriptor. libusb is built for Android in the app
|
||||
renamed to `usb/usb_android.cpp`'s, which start libusb without its device
|
||||
discovery and give it that descriptor, wrapped, as the only device on the
|
||||
bus. Tested on the build host on D-Modem-RE's fake pico-serial Line
|
||||
sticks and simulated exchange (`native-test/usb_line_test.py`: dialling,
|
||||
sticks and Agere modems, and simulated exchange (`native-test/usb_line_test.py`, its `agere` run with the tests' own ROM patches: dialling,
|
||||
caller ID, answering, CONNECT 33600, data each way, hanging up, unplugged);
|
||||
not yet on a phone with a real stick. The phone's speaker isn't fed on
|
||||
this line.
|
||||
|
||||
@@ -34,6 +34,8 @@ android {
|
||||
getByName("main") {
|
||||
// proot, built for each ABI (below)
|
||||
jniLibs.directories.add(layout.buildDirectory.dir("proot/jniLibs").get().asFile.path)
|
||||
// the Agere USB modem's ROM patches (D-Modem-RE's firmware/agere, below)
|
||||
assets.directories.add(layout.buildDirectory.dir("generated/firmware-assets").get().asFile.path)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,3 +161,13 @@ for (abi in prootAbis) {
|
||||
buildProot.configure { dependsOn(t) }
|
||||
}
|
||||
tasks.named("preBuild") { dependsOn(buildProot) }
|
||||
|
||||
// the Agere USB modem's ROM patches, as D-Modem-RE ships them (firmware/agere: Agere's, under Agere's
|
||||
// licence, its LICENSE and NOTICE.md with them), into the APK's assets as firmware/agere; installed in
|
||||
// the app's files when an Agere modem is the line (UsbModems)
|
||||
val agereFirmware = tasks.register<Copy>("agereFirmware") {
|
||||
description = "Copies the Agere USB modem's ROM patches from D-Modem-RE into the assets"
|
||||
from(rootProject.file("external/d-modem-re/firmware/agere"))
|
||||
into(layout.buildDirectory.dir("generated/firmware-assets/firmware/agere"))
|
||||
}
|
||||
tasks.named("preBuild") { dependsOn(agereFirmware) }
|
||||
@@ -39,12 +39,15 @@ set_target_properties(dmodem_engine PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
if(ANDROID)
|
||||
# the USB modems (D-Modem-RE's usb_line.cpp: a SmartUSB56, a
|
||||
# pico-serial Line stick) on the device Android opened for the app:
|
||||
# pico-serial Line stick, an Agere USB 2.0 soft modem, usb_agere.cpp,
|
||||
# its ROM patches from the app's assets, DMODEM_AGERE_FIRMWARE) on the
|
||||
# device Android opened for the app:
|
||||
# libusb built here, and usb_line.cpp's three calls that look for the
|
||||
# device renamed to usb/usb_android.cpp's, which give it that one
|
||||
include(usb/libusb.cmake)
|
||||
target_sources(dmodem_engine PRIVATE usb/usb_modem.cpp
|
||||
usb/usb_android.cpp ${DMODEM_RE_DIR}/dmodemd/usb_line.cpp
|
||||
${DMODEM_RE_DIR}/dmodemd/usb_agere.cpp
|
||||
${DMODEM_RE_DIR}/dmodemd/si3056.cpp)
|
||||
set_source_files_properties(${DMODEM_RE_DIR}/dmodemd/usb_line.cpp
|
||||
PROPERTIES COMPILE_DEFINITIONS
|
||||
|
||||
@@ -199,6 +199,10 @@ class ModemService : Service() {
|
||||
is UsbModems.Opened.Device -> {
|
||||
usbModem = o
|
||||
log("line: the ${o.kind.described}")
|
||||
// (its ROM patches where D-Modem-RE looks for them)
|
||||
if (o.kind == UsbModems.Kind.AGERE) {
|
||||
runCatching { UsbModems.installAgereFirmware(this) }.onFailure { log("the Agere modem's patches: $it") }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -240,7 +244,7 @@ class ModemService : Service() {
|
||||
sipLogLevel = settings.sipLogLevel,
|
||||
peer = settings.peer,
|
||||
usbFd = usbModem?.connection?.fileDescriptor ?: -1,
|
||||
usbRate = UsbModems.RATE,
|
||||
usbRate = usbModem?.kind?.rate ?: UsbModems.RATE,
|
||||
// (Bluetooth's way is slower: more room for the samples on it)
|
||||
peerLeadMs = when (settings.line) {
|
||||
ModemSettings.LINE_BLUETOOTH -> 200
|
||||
|
||||
@@ -23,20 +23,23 @@ import kotlin.coroutines.resume
|
||||
* The app runs the modem itself: they carry its samples to the line.
|
||||
*/
|
||||
object UsbModems {
|
||||
enum class Kind(val vendor: Int, val product: Int, val label: String) {
|
||||
SMART_USB56(0x0483, 0x7554, "SmartUSB56"),
|
||||
PICO_LINE(0x1209, 0x0002, "pico-serial Line"),
|
||||
enum class Kind(val vendor: Int, val products: List<Int>, val label: String, val rate: Int) {
|
||||
SMART_USB56(0x0483, listOf(0x7554), "SmartUSB56", 9600),
|
||||
PICO_LINE(0x1209, listOf(0x0002), "pico-serial Line", 9600),
|
||||
/** its ROM patched with Agere's bulk patch as it starts (D-Modem-RE ships them; [installAgereFirmware]) */
|
||||
AGERE(0x047E, listOf(0x2892, 0x2828), "Agere USB 2.0 modem", 8000),
|
||||
;
|
||||
|
||||
/** "SmartUSB56 (USB 0483:7554)" */
|
||||
val described: String get() = "$label (USB %04x:%04x)".format(vendor, product)
|
||||
val described: String
|
||||
get() = "$label (USB " + products.joinToString("/") { "%04x:%04x".format(vendor, it) } + ")"
|
||||
}
|
||||
|
||||
/** the modems' rate (Hz): both take 9600, the Si3056's default (dmodemd's too) */
|
||||
/** the modems' rate (Hz) but the Agere's: both take 9600, the Si3056's default (dmodemd's too); the Agere 8000 */
|
||||
const val RATE = 9600
|
||||
|
||||
/** which of them a USB device with these IDs is, or null */
|
||||
fun kindOf(vendor: Int, product: Int): Kind? = Kind.entries.firstOrNull { it.vendor == vendor && it.product == product }
|
||||
fun kindOf(vendor: Int, product: Int): Kind? = Kind.entries.firstOrNull { it.vendor == vendor && product in it.products }
|
||||
|
||||
fun kindOf(d: UsbDevice): Kind? = kindOf(d.vendorId, d.productId)
|
||||
|
||||
@@ -57,6 +60,22 @@ object UsbModems {
|
||||
class Failed(val why: String) : Opened
|
||||
}
|
||||
|
||||
/**
|
||||
* The Agere modem's ROM patches (D-Modem-RE's firmware/agere: Agere's, under Agere's licence, in the
|
||||
* APK's assets) in the app's files, and D-Modem-RE told where (DMODEM_AGERE_FIRMWARE): their directory
|
||||
*/
|
||||
fun installAgereFirmware(context: Context): java.io.File {
|
||||
val dir = java.io.File(context.filesDir, "firmware/agere").apply { mkdirs() }
|
||||
val assets = context.assets
|
||||
for (name in assets.list("firmware/agere").orEmpty()) {
|
||||
val out = java.io.File(dir, name)
|
||||
val bytes = assets.open("firmware/agere/$name").use { it.readBytes() }
|
||||
if (!out.exists() || !out.readBytes().contentEquals(bytes)) out.writeBytes(bytes)
|
||||
}
|
||||
android.system.Os.setenv("DMODEM_AGERE_FIRMWARE", dir.path, true)
|
||||
return dir
|
||||
}
|
||||
|
||||
private const val ACTION_PERMISSION = "com.neodesktop.dmodem.USB_MODEM_PERMISSION"
|
||||
|
||||
/**
|
||||
@@ -66,7 +85,9 @@ object UsbModems {
|
||||
suspend fun open(context: Context, askMs: Long = 60_000): Opened {
|
||||
val m = context.getSystemService(UsbManager::class.java) ?: return Opened.Failed("this phone has no USB host")
|
||||
val (dev, kind) = plugged(context).firstOrNull()
|
||||
?: return Opened.Failed("no USB modem plugged in: a ${Kind.SMART_USB56.described} or a ${Kind.PICO_LINE.described}")
|
||||
?: return Opened.Failed(
|
||||
"no USB modem plugged in: a ${Kind.SMART_USB56.described}, a ${Kind.PICO_LINE.described} or an ${Kind.AGERE.described}",
|
||||
)
|
||||
if (!m.hasPermission(dev)) {
|
||||
val allowed = withTimeoutOrNull(askMs) { ask(context, m, dev) } ?: false
|
||||
if (!allowed) return Opened.Failed("the ${kind.label} wasn't allowed: allow D-Modem to use it, then start the modem again")
|
||||
|
||||
@@ -102,8 +102,9 @@ fun UsbLineFields() {
|
||||
val plugged = remember { com.neodesktop.dmodem.modem.UsbModems.describe(context) }
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text(
|
||||
"The modem dials and answers a real phone line through a USB modem: a Smart Link SmartUSB56, or a " +
|
||||
"pico-serial Line stick, both with caller ID (the stick takes the country's line settings too). The phone runs the modem; " +
|
||||
"The modem dials and answers a real phone line through a USB modem: a Smart Link SmartUSB56, a " +
|
||||
"pico-serial Line stick (with the country's line settings) or an Agere USB 2.0 soft modem (Agere's ROM patches " +
|
||||
"come with the app), all with caller ID. The phone runs the modem; " +
|
||||
"the USB one is its line. No SIP account or network needed. Android asks once whether D-Modem may use it.",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
)
|
||||
|
||||
@@ -9,9 +9,12 @@
|
||||
<usb-device vendor-id="6790" />
|
||||
<!-- Prolific PL2303 -->
|
||||
<usb-device vendor-id="1659" />
|
||||
<!-- the USB modems that can be the modem's line (UsbModems): a SmartUSB56 (0483:7554), a pico-serial Line (1209:0002) -->
|
||||
<!-- the USB modems that can be the modem's line (UsbModems): a SmartUSB56 (0483:7554), a pico-serial Line (1209:0002), an Agere (047E:2892, 047E:2828) -->
|
||||
<usb-device vendor-id="1155" product-id="30036" />
|
||||
<usb-device vendor-id="4617" product-id="2" />
|
||||
<!-- an Agere USB 2.0 soft modem (047E:2892, 047E:2828) -->
|
||||
<usb-device vendor-id="1150" product-id="10386" />
|
||||
<usb-device vendor-id="1150" product-id="10280" />
|
||||
<!-- any CDC-ACM (communications class) device -->
|
||||
<usb-device class="2" />
|
||||
</resources>
|
||||
@@ -0,0 +1,43 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Neo-Desktop
|
||||
package com.neodesktop.dmodem.modem
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import java.io.File
|
||||
import java.security.MessageDigest
|
||||
|
||||
/**
|
||||
* The Agere USB modem's ROM patches: in the APK's assets as D-Modem-RE
|
||||
* ships them, installed in the app's files byte for byte (their SHA-256
|
||||
* sums D-Modem-RE's), with Agere's licence beside them.
|
||||
*/
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [35])
|
||||
class AgereFirmwareTest {
|
||||
@Test
|
||||
fun installedAsShipped() {
|
||||
val ctx = ApplicationProvider.getApplicationContext<android.content.Context>()
|
||||
val dir = UsbModems.installAgereFirmware(ctx)
|
||||
val sums = File(dir, "SHA256SUMS").readLines().filter { it.isNotBlank() }.associate { l ->
|
||||
val (sum, name) = l.trim().split(Regex("\\s+"), limit = 2)
|
||||
name.removePrefix("*") to sum
|
||||
}
|
||||
assertEquals(4, sums.size)
|
||||
for ((name, sum) in sums) {
|
||||
val f = File(dir, name)
|
||||
assertTrue(name, f.isFile)
|
||||
val got = MessageDigest.getInstance("SHA-256").digest(f.readBytes()).joinToString("") { "%02x".format(it) }
|
||||
assertEquals(name, sum, got)
|
||||
}
|
||||
assertTrue(File(dir, "LICENSE").isFile)
|
||||
assertTrue(File(dir, "NOTICE.md").isFile)
|
||||
// (again: nothing changes)
|
||||
assertEquals(dir, UsbModems.installAgereFirmware(ctx))
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,9 @@ class UsbModemsTest {
|
||||
fun theTwoModemsByTheirIds() {
|
||||
assertEquals(UsbModems.Kind.SMART_USB56, UsbModems.kindOf(0x0483, 0x7554))
|
||||
assertEquals(UsbModems.Kind.PICO_LINE, UsbModems.kindOf(0x1209, 0x0002))
|
||||
assertEquals(UsbModems.Kind.AGERE, UsbModems.kindOf(0x047E, 0x2892))
|
||||
assertEquals(UsbModems.Kind.AGERE, UsbModems.kindOf(0x047E, 0x2828))
|
||||
assertNull(UsbModems.kindOf(0x047E, 0x1234))
|
||||
// (the pico-serial board, an STM32's other devices: not modems)
|
||||
assertNull(UsbModems.kindOf(0x1209, 0x0001))
|
||||
assertNull(UsbModems.kindOf(0x0483, 0x5740))
|
||||
@@ -21,5 +24,9 @@ class UsbModemsTest {
|
||||
fun describedWithTheirIds() {
|
||||
assertEquals("SmartUSB56 (USB 0483:7554)", UsbModems.Kind.SMART_USB56.described)
|
||||
assertEquals("pico-serial Line (USB 1209:0002)", UsbModems.Kind.PICO_LINE.described)
|
||||
assertEquals("Agere USB 2.0 modem (USB 047e:2892/047e:2828)", UsbModems.Kind.AGERE.described)
|
||||
// (the Agere runs at 8000 Hz, the others at 9600)
|
||||
assertEquals(8000, UsbModems.Kind.AGERE.rate)
|
||||
assertEquals(9600, UsbModems.Kind.PICO_LINE.rate)
|
||||
}
|
||||
}
|
||||
Vendored
+1
-1
Submodule external/d-modem-re updated: 79e00fa2aa...a30aa39dd5.
@@ -92,7 +92,7 @@ set(_app ${CMAKE_CURRENT_SOURCE_DIR}/../app/src/main/cpp)
|
||||
set(_dmd ${DMODEM_RE_DIR}/dmodemd)
|
||||
add_library(dmodem_engine_usb STATIC ${_app}/engine.cpp
|
||||
${_app}/peer_modem.cpp ${_app}/dmodem_engine.cpp
|
||||
${_app}/usb/usb_modem.cpp ${_dmd}/usb_line.cpp ${_dmd}/si3056.cpp
|
||||
${_app}/usb/usb_modem.cpp ${_dmd}/usb_line.cpp ${_dmd}/usb_agere.cpp ${_dmd}/si3056.cpp
|
||||
usb_fake_device.cpp ${_dmd}/test/fake_pico_line.cpp)
|
||||
target_include_directories(dmodem_engine_usb PUBLIC ${_app})
|
||||
target_include_directories(dmodem_engine_usb SYSTEM PUBLIC
|
||||
@@ -112,3 +112,25 @@ add_test(NAME usb_line COMMAND python3
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/usb_line_test.py $<TARGET_FILE:usb_host>
|
||||
$<TARGET_FILE:usb_exchange>)
|
||||
set_tests_properties(usb_line PROPERTIES TIMEOUT 300)
|
||||
|
||||
# the same on D-Modem-RE's fake Agere USB 2.0 soft modems
|
||||
# (test/fake_agere.cpp): their ROM patches the tests' own, in a firmware
|
||||
# directory as the app installs Agere's (DMODEM_AGERE_FIRMWARE)
|
||||
add_library(dmodem_engine_agere STATIC ${_app}/engine.cpp
|
||||
${_app}/peer_modem.cpp ${_app}/dmodem_engine.cpp
|
||||
${_app}/usb/usb_modem.cpp ${_dmd}/usb_line.cpp ${_dmd}/usb_agere.cpp
|
||||
${_dmd}/si3056.cpp usb_fake_device.cpp ${_dmd}/test/fake_agere.cpp)
|
||||
target_include_directories(dmodem_engine_agere PUBLIC ${_app})
|
||||
target_include_directories(dmodem_engine_agere SYSTEM PUBLIC
|
||||
${DMODEM_LIBUSB_SRC}/libusb)
|
||||
target_compile_definitions(dmodem_engine_agere PUBLIC DMODEM_ENGINE_USB)
|
||||
target_link_libraries(dmodem_engine_agere PUBLIC dmodem_sip)
|
||||
|
||||
add_executable(agere_host usb_host.cpp)
|
||||
target_link_libraries(agere_host PRIVATE dmodem_engine_agere Threads::Threads)
|
||||
target_compile_options(agere_host PRIVATE -Wall -Wextra)
|
||||
|
||||
add_test(NAME agere_line COMMAND python3
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/usb_line_test.py $<TARGET_FILE:agere_host>
|
||||
$<TARGET_FILE:usb_exchange> agere)
|
||||
set_tests_properties(agere_line PROPERTIES TIMEOUT 300)
|
||||
@@ -15,12 +15,18 @@ void usb_use_fd(int) {}
|
||||
|
||||
} // namespace dmodem_android
|
||||
|
||||
/* what the fake leaves to the real libusb (upstream's tests preload the
|
||||
/* (weak: a fake that has its own wins) what the fake leaves to the real libusb (upstream's tests preload the
|
||||
fake in front of it; here it is linked in alone): the device's ports,
|
||||
for wake on ring's sysfs switch (UsbLine::arm_wake(), with set_wake()
|
||||
alone), unknown */
|
||||
extern "C" int LIBUSB_CALL libusb_get_port_numbers(libusb_device *,
|
||||
extern "C" __attribute__((weak)) int LIBUSB_CALL libusb_get_port_numbers(libusb_device *,
|
||||
uint8_t *, int)
|
||||
{
|
||||
return LIBUSB_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/* (the Agere modem's speed check: the fake stick isn't one) */
|
||||
extern "C" __attribute__((weak)) int LIBUSB_CALL libusb_get_device_speed(libusb_device *)
|
||||
{
|
||||
return LIBUSB_SPEED_HIGH;
|
||||
}
|
||||
@@ -2,12 +2,15 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright (C) 2026 Neo-Desktop
|
||||
#
|
||||
# usb_line_test.py <usb_host> <line_exchange>: the app's engine on a USB
|
||||
# modem's line (usb_modem.h), two of them (usb_host) on D-Modem-RE's fake
|
||||
# pico-serial Line sticks whose lines are the simulated exchange's, 1001
|
||||
# and 1002 (as D-Modem-RE's pico_line_test.py runs dmodemd --usb):
|
||||
# usb_line_test.py <usb_host> <line_exchange> [agere]: the app's engine on
|
||||
# a USB modem's line (usb_modem.h), two of them (usb_host) on D-Modem-RE's
|
||||
# fake pico-serial Line sticks (or, agere, its fake Agere USB 2.0 soft
|
||||
# modems at 8000 Hz, their ROM patches the tests' own in a firmware
|
||||
# directory, DMODEM_AGERE_FIRMWARE, as the app installs Agere's) whose
|
||||
# lines are the simulated exchange's, 1001 and 1002 (as D-Modem-RE's
|
||||
# pico_line_test.py and agere_test.py run dmodemd --usb):
|
||||
#
|
||||
# - each says it's on a pico-serial Line (ATI3);
|
||||
# - each says what it's on (ATI3);
|
||||
# - 1001 dials 1002 (ATX4: after the dial tone, in DTMF); 1002 rings,
|
||||
# shows the caller ID (AT#CID=1), answers at the second ring (ATS0=2);
|
||||
# both CONNECT, and the engine's status says online; a line of text
|
||||
@@ -17,8 +20,19 @@
|
||||
import os, re, shutil, subprocess, sys, tempfile, threading, time
|
||||
|
||||
host, exchange = sys.argv[1], sys.argv[2]
|
||||
rate = "9600"
|
||||
agere = len(sys.argv) > 3 and sys.argv[3] == "agere"
|
||||
rate = "8000" if agere else "9600"
|
||||
tmp = tempfile.mkdtemp(prefix="dmodem-usb-line-")
|
||||
device = b"Agere USB 2.0 \\(Mercury\\)" if agere else b"pico-serial Line \\(Si3056\\)"
|
||||
firmware = os.path.join(tmp, "firmware")
|
||||
if agere:
|
||||
# the tests' patches (D-Modem-RE's agere_patch.h test_patch(), as its
|
||||
# agere_test.py makes them), a file each, as Agere's are installed
|
||||
os.makedirs(firmware)
|
||||
LENS = (748, 748, 1156, 508)
|
||||
for i, n in enumerate(LENS):
|
||||
with open(os.path.join(firmware, "patch%d.bin" % i), "wb") as f:
|
||||
f.write(bytes((k * 31 + i * 77 + 5 + (k >> 8)) & 0xff for k in range(n)))
|
||||
|
||||
procs = []
|
||||
events = []
|
||||
@@ -35,7 +49,12 @@ class Modem:
|
||||
"""the engine (usb_host) on line <n>'s fake stick: its DTE, its log"""
|
||||
def __init__(self, n):
|
||||
self.n = n
|
||||
env = dict(os.environ, FAKE_PICO_LINE_SOCKET=os.path.join(tmp, n + ".sock"))
|
||||
sock = os.path.join(tmp, n + ".sock")
|
||||
if agere:
|
||||
env = dict(os.environ, FAKE_AGERE_SOCKET=sock, DMODEM_AGERE_FIRMWARE=firmware,
|
||||
DMODEM_AGERE_TEST_PATCHES="1")
|
||||
else:
|
||||
env = dict(os.environ, FAKE_PICO_LINE_SOCKET=sock)
|
||||
self.p = subprocess.Popen([host, rate], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, env=env)
|
||||
procs.append(self.p)
|
||||
@@ -97,8 +116,8 @@ try:
|
||||
b = Modem("1002")
|
||||
for m in (a, b):
|
||||
check("%s ATE0" % m.n, m.cmd(b"ATE0", t=15))
|
||||
check("%s ATI3: pico-serial Line" % m.n,
|
||||
m.cmd(b"ATI3", rb"pico-serial Line \(Si3056\)\r\n(\r\n)?OK\r\n"))
|
||||
check("%s ATI3: %s" % (m.n, device.decode().replace("\\", "")),
|
||||
m.cmd(b"ATI3", device + rb"\r\n(\r\n)?OK\r\n"))
|
||||
check("1002 answers at the 2nd ring", b.cmd(b"ATS0=2"))
|
||||
check("1002 caller ID on", b.cmd(b"AT#CID=1"))
|
||||
check("1001 waits for the dial tone", a.cmd(b"ATX4"))
|
||||
|
||||
Reference in new issue
Block a user