wvdial, pppd and default route metric - gentoo

I have this in wvdial.conf:
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0
Modem Type = USB Modem
Phone = *99#
New PPD = yes
ISDN = 0
Username = foo
Init1 = ATZ
Password = foo
Modem = /dev/ttyUSB1
Baud = 9600
Stupid Mode = 0
#Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CFUN=1
Init4 = AT+CGDCONT=1,"ip","internet"
Auto Reconnect = on
(PIN disabled)
This is working for 4G USB Dongle Huawei E3131 # T-mobile.pl.
And now I have 2 questions:
1 How to translate this config to /etc/conf.d/net for connect as net.ppp1 (Gentoo) (I would connecting without wvdial)
2 After connecting I get default route with metric 0, How to change metric to say 100? (I'm interested in setting metric for both wvdial & pppd way)

Related

Check and cast error in Omnet++ TSN. Unable to transmit UDP packets

I am trying to send a UDP packet from Omnett ++ TSN Device to a standard Host through a TSN switch that is connected to a Router.
However, I get the following check_and_cast error:-
check_and_cast(): Cannot cast(inet::physicallayer::signal*)app[0]-0 to type 'inet::physicallayer::EthernetSignalBase *' in module (inet::EthernetMac) of router.eth[0].mac
My omnetpp.ini udp app setup is as follows.
extends = omnetpptsnnetworksample
#Source application
*.tsnDevice1.numApps = 1
*.tsnDevice1.app[0].typename = "UdpSourceApp"
*.tsnDevice1.app[0].source.packetLength = 10B
*.tsnDevice1.app[0].source.productionInterval = 1ms
*.tsnDevice1.app[0].io.destAddress = "ue[0]"
*.tsnDevice1.app[0].io.destPort = 1000
*.tsnDevice1.app[0].source.clockModule = "^.^.clock"
#Sink application
*.standardHost[*].numApps = 1
*.standardHost[*].app[*].typename = "UdpSinkApp"
*.standardHost[*].app[*].io.localPort = 1000
Where did I go wrong?
TsnDevice and TsnSwitch have LayeredEthernetInterface by default, but StandardHost has EthernetInterface. The two interfaces are not compatible (not sure if they should be or not). So by setting standardHost's ethernet interface type to LayeredEthernetInterface, it should work:
*.standardHost[*].eth[*].typename = "LayeredEthernetInterface"

How to use the DIO SPI on ESP32 with espidf?

I'm trying to use the DIO SPI mode on the ESP32 with the espidf (version 4.4).
But I encountered problems.
I have a ram device (ref 23LC1024) than can be accessed with several modes (single, dual, quad).
The single mode works perfectly (can write and read back)
The dual mode creates problems.
Here is how I configure the SPI bus (same setup for single or dual mode)
memset(&config, 0, sizeof(spi_bus_config_t));
config.mosi_io_num = MOSI_PIN;
config.miso_io_num = MISO_PIN;
config.sclk_io_num = SCLK_PIN;
config.quadwp_io_num = -1; // -1 not used
config.quadhd_io_num = -1; // -1 not used
config.flags = SPICOMMON_BUSFLAG_DUAL | SPICOMMON_BUSFLAG_MASTER;
spi_bus_initialize(VSPI_HOST, &config, SPI_DMA_DISABLED); // 0 DMA not used
Now the setup for the device (same setup for single mode or dual):
spi_device_interface_config_t devcfg = {
.clock_speed_hz = freq,
.command_bits = 8,
.address_bits = 24,
.dummy_bits = 8,
.mode = 0, // SPI MODE 0
.flags = 0,
.spics_io_num = _cs,
.queue_size = 1,
.pre_cb = NULL,
.post_cb = NULL};
ESP_ERROR_CHECK(spi_bus_add_device(VSPI_HOST, &devcfg, &data_Ram));
Now the setup for the transaction:
spi_transaction_t t;
memset(&t, 0, sizeof(t)); // Zero out the transaction
t.cmd = WRITE;
t.tx_buffer = data;
t.rx_buffer = NULL;
t.addr = address;
t.length = size * 8;
if (USE_DIO) // configure these flags in case of DIO
t.flags = SPI_TRANS_MODE_DIO | SPI_TRANS_MULTILINE_ADDR | SPI_TRANS_MULTILINE_CMD;
ESP_ERROR_CHECK(spi_device_transmit(data_Ram, &t)); // Transmit!
It works nicely in the single mode but with the dual mode I got the error:
E (1618) spi_master: check_trans_valid(699): Incompatible when setting to both multi-line mode and half duplex mode
Does it mean I cannot use DIO in half duplex mode with the SPI master library?
Is there something I should change in my setup ?
I tried to specify the SPI_DEVICE_HALFDUPLEX flag in the spi_device_interface_config_t. Does not help.
Unfortunately I did not find any example on internet.
Thanks for your heads up!
E (1618) spi_master: check_trans_valid(699): Incompatible when setting to both multi-line mode and half duplex mode means that you cannot use MISO and MOSI for transfering (multiline) AND use them at the same time (full duplex).
Set your device to half duplex to fix the problem:
spi_device_interface_config_t devcfg = {
.flags = SPI_DEVICE_HALFDUPLEX,
...
};
In my experience, SPI_TRANS_MULTILINE_ADDR doesn't work, at least with spi_device_transmit.
If your ram device allows it, try without the "multilined" address and command.

UsbDevice.FromIdAsync returning null in UWP app

I'm currently working on an UWP app which includes USB communication with a custom USB device. I was able to set up a communication channel between a Raspberry Pi 3b and the device and sent some bytes back and forth. It does not work if I run this app on a local machine (Windows 10 build 1809) instead. In this case the call to UsbDevice.FromIdAsync always returns NULL.
I saw some related questions here, here and here with the similar or even the same problem. But none of the solutions mentioned are working for me.
I installed the Win USB driver using following inf-file:
;
; Installs WinUsb
;
[Version]
Signature = "$Windows NT$"
Class = USBDevice
ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
Provider = %ManufacturerName%
CatalogFile = WinUSBInstallation.cat
DriverVer = 12/12/2016,13.54.20.543
[Generic.Section.NTamd64]
%USB\MS_COMP_WINUSB.DeviceDesc% = WINUSB,USB\MS_COMP_WINUSB
; ========== Manufacturer/Models sections ===========
[Manufacturer]
%ManufacturerName% = Standard,NTamd64
[Standard.NTamd64]
%DeviceName% = USB_Install, USB\VID_0483&PID_0001
; ========== Class definition ===========
[ClassInstall32]
AddReg = ClassInstall_AddReg
[ClassInstall_AddReg]
HKR,,,,%ClassName%
HKR,,NoInstallClass,,1
HKR,,SilentInstall,,1
HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%\system32\setupapi.dll,-20"
HKR,,LowerLogoVersion,,5.2
; =================== Installation ===================
[USB_Install]
Include = winusb.inf
Needs = WINUSB.NT
[USB_Install.Services]
Include = winusb.inf
Needs = WINUSB.NT.Services
[USB_Install.HW]
AddReg = Dev_AddReg
[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{9f543223-cede-4fa3-b376-a25ce9a30e74}"
; =================== Strings ===================
[Strings]
ManufacturerName = "Manufacturer"
ClassName = "Universal Serial Bus devices"
DeviceName = "Device"
REG_MULTI_SZ = 0x00010000
The device shows up properly in the device manager without any errors.
I added the device capabilities to the Package.appxmanifest as follows:
<Capabilities>
<DeviceCapability Name="usb">
<Device Id="vidpid:0483 0001">
<Function Type="classId:ff 00 00"/>
<Function Type="name:vendorSpecific"/>
</Device>
</DeviceCapability>
</Capabilities>
And in my code I try to open the device as follows:
byte deviceClass = 0xff;
byte deviceSubclass = 0x00;
var myDevices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(
Windows.Devices.Usb.UsbDevice.GetDeviceClassSelector(
new Windows.Devices.Usb.UsbDeviceClass() {
ClassCode = deviceClass,
SubclassCode = deviceSubclass
}
)
);
UsbDevice device = null;
var numDevices = myDevices.Count;
foreach (var d in myDevices) {
device = await UsbDevice.FromIdAsync(d.Id);
if (device == null) {
// Device could not be found.
}
else {
// Found device.
}
}
The call to FindAllAsync does find a single device which has the correct id. But calling FromIdAsync always returns NULL. As mentioned before this all works on a Raspberry Pi 3b but not locally on my desktop machine or any other machine I tried out.
I searched for a few days now and I don't know what I'm still overlooking or missing. Any suggestions what else I can do?
Best regards

How to send UDP packet in a wireless network from multi-host simultaneously in INET/Veins_inet

Greeting all,
I am trying to edit Veins_inet (square example)to the following scenario:
node#1,2 send UDP packet to node#0 at time 15s and stop sending at 18s.
but when I do that the UDP packet not sent simultaneously!
How can I make the two node target node#0 simultaneously?
here part of .ini file
# UDPBasicApp
MyScenario.node[1..2].numUdpApps = 2
MyScenario.node[1..2].udpApp[0].typename = "UDPBasicApp"
MyScenario.node[1..2].udpApp[0].destAddresses = "224.0.0.1"
MyScenario.node[1..2].udpApp[0].multicastInterface = "wlan0"
MyScenario.node[1..2].udpApp[0].joinLocalMulticastGroups = true
#MyScenario.node[1..2].udpApp[0].localPort = 9001
MyScenario.node[1..2].udpApp[0].destPort = 9001
MyScenario.node[1..2].udpApp[0].messageLength = 100B
MyScenario.node[1..2].udpApp[0].startTime = uniform(0s, 5s)
MyScenario.node[1..2].udpApp[0].sendInterval = 5s #uniform(0.01s, 0.05s)
#atttack
MyScenario.node[1..2].udpApp[1].typename = "UDPBasicApp"
#MyScenario.node[1..2].udpApp[1].destAddresses = "224.0.0.1"
MyScenario.node[1..2].udpApp[1].multicastInterface = "wlan0"
MyScenario.node[1..2].udpApp[1].joinLocalMulticastGroups = true
# MyScenario.node[1..2].udpApp[1].localPort = 9001
MyScenario.node[1..2].udpApp[1].destAddresses = "node[0]"
MyScenario.node[1..2].udpApp[1].destPort = 9001
MyScenario.node[1..2].udpApp[1].messageLength = 100B
MyScenario.node[1..2].udpApp[1].startTime = 15s #uniform(0s, 5s)
MyScenario.node[1..2].udpApp[1].stopTime = 18s
MyScenario.node[1..2].udpApp[1].sendInterval = 0.01s #uniform(0.01s, 0.05s)
MyScenario.node[1..2].udpApp[1].packetName = "attack"
Any help will be very appreciated to help me to move forward in my project

gammu phones tables with multiple modem port

EDIT: I know, after some research, this problem caused by IMEI field
in phones tables as primary, if we using modem pool like wavecome with
16 port, gammu detect just one IMEI
i have 1 modem connected with 16 port of sim card,each config connected to same database on my server,send and receive sms all working like a charm, each port have smsd services, like
gammu-smsd -c /etc/gammu-smsdrc-modem1 --pid /var/run/gammu-smsdrc-modem1 --daemon
gammu-smsd -c /etc/gammu-smsdrc-modem2 --pid /var/run/gammu-smsdrc-modem2 --daemon
each port have their own PhoneID, like modem1 and modem2, the problem is
why phones tables in gammu databases keep replacing the data with last gammu-smsd services run ?
ex:
if i run the first config, then phones tables will contains all informations , like signal, IMEI from 1st port, but when i run 2nd gammu-smsd data from 1st port will gone, changed from 2nd port config
here is my smsdrc config from modem1 /etc/gammu-smsdrc-modem1
[gammu]
port = /dev/ttyUSB0
model =
connection = at115200
synchronizetime = yes
logfile = /var/log/gammu-smsdrc-modem1
logformat = nothing
use_locking =
gammuloc =
[smsd]
service=sql
logfile=/var/log/gammu-smsdrc-modem1
debuglevel=0
Driver=native_mysql
User=root
Password=root
PC=localhost
Database=test
PhoneID=modem1
here is my smsd config from modem2 /etc/gammu-smsdrc-modem2
[gammu]
port = /dev/ttyUSB1
model =
connection = at115200
synchronizetime = yes
logfile = /var/log/gammu-smsdrc-modem2
logformat = nothing
use_locking =
gammuloc =
[smsd]
service=sql
logfile=/var/log/gammu-smsdrc-modem2
debuglevel=0
Driver=native_mysql
User=root
Password=root
PC=localhost
Database=test
PhoneID=modem2
after some reading on API Doc of gammu, i have figure it out, yes like the first one, it because i use one modem with 16 port of sim card, gammu just detect singel IMEI even the modem have 16 port, quick answer for my question is no configureable file can handle that problem, so we have to modify some line og code from smsd/services/sql.c
if (SMSDSQL_option(Config, SQL_QUERY_DELETE_PHONE, "delete_phone",
"DELETE FROM phones WHERE ", ESCAPE_FIELD("IMEI"), " = %I", NULL) != ERR_NONE) {
return ERR_UNKNOWN;
}
.......
.......
.......
if (SMSDSQL_option(Config, SQL_QUERY_UPDATE_RECEIVED, "update_received",
"UPDATE phones SET ",
ESCAPE_FIELD("Received"), " = ", ESCAPE_FIELD("Received"), " + 1"
" WHERE ", ESCAPE_FIELD("IMEI"), " = %I", NULL) != ERR_NONE) {
return ERR_UNKNOWN;
}
the final code will be
if (SMSDSQL_option(Config, SQL_QUERY_DELETE_PHONE, "delete_phone",
"DELETE FROM phones WHERE ", ESCAPE_FIELD("ID"), " = %P", NULL) != ERR_NONE) {
return ERR_UNKNOWN;
}
.......
.......
.......
if (SMSDSQL_option(Config, SQL_QUERY_UPDATE_RECEIVED, "update_received",
"UPDATE phones SET ",
ESCAPE_FIELD("Received"), " = ", ESCAPE_FIELD("Received"), " + 1"
" WHERE ", ESCAPE_FIELD("ID"), " = %P", NULL) != ERR_NONE) {
return ERR_UNKNOWN;
}
and recompile gammu as usual, and modify phones tables to set ID as Primary key, i'm not expert in c, hope some one can made a good change for better result, but for me it's enough for temp used.

Resources