Assistance in trying to detect when an actual smart-card is inserted into a USB smart-card reader attached to a handheld Android device.
I have an existing (and completely working) instance of the BroadcastReceiver and am successfully detecting when the actual smart-card reader device is connected via the filters of
myFilter.AddAction(UsbManager.ActionUsbDeviceAttached);
myFilter.AddAction(UsbManager.ActionUsbDeviceDetached);
What I am looking for now is when an actual card is inserted or removed from the device.
By using ADB (Android Debug Bridge) program and using the logcat, I can redirect the output to a file to see what is going on such as
adb logcat -c (to clear log)
adb logcat > c:\SomeFolder\MyAndroidLog.txt
Before starting the log above, I have my handheld device ready, the smart-card reader attached. Immediately after that is when I clear the log and start a fresh capture. Then I insert my smart card, wait a few seconds and then stop the log with Ctrl+C. Upon viewing the log, I am getting
--------- beginning of main
10-07 11:43:26.458 827 827 I chatty : uid=1000(system) /system/bin/surfaceflinger expire 14 lines
10-07 11:43:26.459 827 827 I ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
10-07 11:43:26.861 556 556 W hwservicemanager: getTransport: Cannot find entry vendor.qti.hardware.servicetracker#1.0::IServicetracker/default in either framework or device manifest.
10-07 11:43:26.925 556 556 I chatty : uid=1000(system) hwservicemanage identical 14 lines
10-07 11:43:26.928 556 556 W hwservicemanager: getTransport: Cannot find entry vendor.qti.hardware.servicetracker#1.0::IServicetracker/default in either framework or device manifest.
10-07 11:43:26.930 7529 7529 D BoundBrokerSvc: onUnbind: Intent { act=com.google.android.gms.feedback.internal.IFeedbackService dat=chimera-action:com.google.android.gms.feedback.internal.IFeedbackService cmp=com.google.android.gms/.chimera.GmsBoundBrokerService }
10-07 11:43:27.481 827 827 I ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
10-07 11:43:27.483 827 827 I chatty : uid=1000(system) /system/bin/surfaceflinger identical 2 lines
10-07 11:43:27.484 827 827 I ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
10-07 11:43:27.780 1170 1170 I HSMCOUNTER: Wrote to EEPROM: ret: 0
10-07 11:43:28.444 827 827 I ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
So it is showing some context of a ConfigStore, but nothing that indicates the "intent" action that other activities are capturing such as when the USB device is connected such as:
10-07 12:05:15.068 1512 1828 I ActivityManager: START u0 {act=android.hardware.usb.action.USB_DEVICE_ATTACHED flg=0x11000000 cmp=com.gemalto.gempcsc.gempcscserviceactivity/com.gemalto.gempcsc.gempcscservice.USBBroadcastReceiver (has extras)} from uid 1000
Additionally, if there is a generic way to capture ALL intents going on vs having to manually add all filters and not even knowing what they all COULD be, might help me narrow it down.
You need to talk to the reader using the CCID protocol. See my previous answer.
For example (sequence numbers in bold):
Send PC_to_RDR_GetSlotStatus (message 0x65 for slot 0):
-> 65000000000000000000
And receive RDR_to_PC_SlotStatus (message 0x81):
Example response for no card present:
<- 81000000000000020000
Example response for inserted unpowered card
<- 81000000000000010000
Below is a base-64 encoded wireshark USB trace detecting card in a GemPC Twin Reader(decode it to binary file and open it in Wireshark, then right-click any packet and select "Decode As...", change to "USB Device" tab, select "USBCCID" protocol and click "OK"):
-----BEGIN PCAP-NG CAPTURE FILE-----
H4sIAAAAAAAAA+Pi5eWSYWBg8LXRlmIE0v+hACQG4usA8R0GEGBhYGJgZygtTsrNzzNg4ATKsjFA
AEgNiJ0D5X96xcrA/SrFzgvIBmGGA9Pfnpn0/38wM5MCI4Muw8opHskg4dO6rAy9QLu4gGwuBtwg
FYmdg8WumteYdjkzN6HYZaPPClaP0y4mCNWIxMNml7LHFLhdB8S6FiH7aw3ULuWjbCT4iw2nvxZ7
YtoF8xfMrsXH2EjwFxsjzC5WNLsi2HztGRlkGJzzS/NKUouKFQqK8ssyU1JTFJIqFVJKcwuSEwuY
GDjAas8cN7NjhrIDgPpYgOwUZohZrEA2MgDZAQDbbEGJZAIAAA==
-----END PCAP-NG CAPTURE FILE-----
(Note: Sequence numbers in capture file have holes as packets are extracted from a longer dump)
Related
TL;DR:
Here is my question:
Can a ffmpeg process recording a rtsp stream run for 10 years or will it break down at some point, given there are no issues with storage and the stream? Glad for any experience like ( "this process has run for x weeks or days)
I have a task to enable my client to record and archive rtsp cam recordings. They should be restreamable and searchable so i opted for mpegts for fast cutting and concatenation, and restreaming as Video on Demand at a later point. This was all fun and games until a new recent requirement, that this should be stable for 10 years.
My FFMPEG Arguments look like this:
-hide_banner -rtsp_transport tcp -i rtsp://MYRTSPURL -threads 8 -pix_fmt yuvj420p -map 0 -c:v h264 -b:v 2M -bf 0 -muxpreload 0 -muxdelay 0 -force_key_frames "expr:gte(t,n_forced0.5)" -strftime 1 -f segment -segment_time 60 -segment_format mpegts -reset_timestamps 1 C:\RecorderTest\capture-%Y-%m-%d_%H-%M-%S.ts -pix_fmt yuvj420p -map 0 -c:v h264 -b:v 200k -bf 0 -muxpreload 0 -muxdelay 0 -force_key_frames "expr:gte(t,n_forced0.5)" -s 192:144 -strftime 1 -f segment -segment_time 60 -segment_format mpegts -reset_timestamps 1 C:\RecorderTest\capture-%Y-%m-%d_%H-%M-%S_preview.ts
which I utilize trough a C# Process. It works quite well so far but I noticed that despite I have set -reset_timestamps 1 the StdErr Progress Output is not resetting but keeps increasing.
FFMPEG STDERR says: frame= 1840 fps= 30 q=28.0 q=22.0 size=N/A time=00:00:59.80 bitrate=N/A dup=0 drop=2 speed=0.983x
FFMPEG STDERR says: [segment # 0000023d8c5e8b40] Opening 'C:\RecorderTest\capture-2022-03-01_11-54-57_preview.ts' for writing
FFMPEG STDERR says: [segment # 0000023d8c5ee940] Opening 'C:\RecorderTest\capture-2022-03-01_11-54-57.ts' for writing
FFMPEG STDERR says: frame= 1855 fps= 30 q=28.0 q=22.0 size=N/A time=00:01:00.30 bitrate=N/A dup=0 drop=2 speed=0.983x
So the time value is increasing and not resetting. Now I fear that this could lead to some undefined behavior. Does anyone know where I could check in ffmpeg source if the case that this time index reaches the max value is catched or if the process will crash by then?
I am trying to get the battery level of my headset device with bluetooth 4.1 with AT commands from Windows using the Handsfree Profile (HFP).
I have extracted the bluetooth log from my Android phone (which is able to get the battery level) and the headset is using HFP to send AT command with the battery information (AT+IPHONEACCEV), this is one of the packets extracted from the log (with wireshark):
Frame 1122: 38 bytes on wire (304 bits), 38 bytes captured (304 bits)
Encapsulation type: Bluetooth H4 with linux header (99)
Arrival Time: Jul 16, 2020 12:18:16.449232000 Romance Daylight Time
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1594894696.449232000 seconds
[Time delta from previous captured frame: 0.001885000 seconds]
[Time delta from previous displayed frame: 0.018263000 seconds]
[Time since reference or first frame: 21.363811000 seconds]
Frame Number: 1122
Frame Length: 38 bytes (304 bits)
Capture Length: 38 bytes (304 bits)
[Frame is marked: False]
[Frame is ignored: False]
Point-to-Point Direction: Received (1)
[Protocols in frame: bluetooth:hci_h4:bthci_acl:btl2cap:btrfcomm:bthfp]
Bluetooth
[Source: GNAudio_xxxxx (AA:BB:CC:DD:EE:FF)]
[Destination: SamsungE_xxxxx (FF:EE:DD:CC:BB:AA)]
Bluetooth HCI H4
[Direction: Rcvd (0x01)]
HCI Packet Type: ACL Data (0x02)
Bluetooth HCI ACL Packet
Bluetooth L2CAP Protocol
Bluetooth RFCOMM Protocol
Address: E/A flag: 1, C/R flag: 0, Direction: 0, Channel: 2
Control: Frame type: Unnumbered Information with Header check (UIH) (0xef), P/F flag: 0
Payload length: 25
Frame Check Sequence: 0xbf
Bluetooth HFP Profile
[Role: HS - Headset (2)]
AT Stream: AT+IPHONEACCEV=2,1,5,2,0\r
Command 0: +IPHONEACCEV
Command Line Prefix: AT
Command: +IPHONEACCEV (Apple Bluetooth Headset Battery Level Indication)
Type: Action Command (0x003d)
Parameters
Count: 2
Key: Battery Level (1)
Value: 5
Key: Dock State (2)
Value: 0
Now, I am trying to do get this AT commands from the headset in my Windows C# application using the 32feet (InTheHand.Net.Bluetooth) library. To do so I try to connect to the headset using BluetoothService.Handsfree:
BluetoothDevicePicker picker = new BluetoothDevicePicker();
BluetoothDeviceInfo device = await picker.PickSingleDeviceAsync();
BluetoothClient cli = new BluetoothClient();
//device.SetServiceState(BluetoothService.Handsfree, true);
cli.Connect(device.DeviceAddress, BluetoothService.Handsfree);
if (cli.Connected) MessageBox.Show("OK");
NetworkStream stream;
stream = cli.GetStream();
if (stream.CanRead)
{
byte[] buff = new byte[1024];
int n = 0;
StringBuilder str = new StringBuilder();
while (stream.DataAvailable)
{
n = await stream.ReadAsync(buff, 0, buff.Length);
str.AppendFormat("{0}", Encoding.ASCII.GetString(buff, 0, n));
}
MessageBox.Show(str.ToString());
}
When executing the code it gives the following error in cli.Connect(device.DeviceAddress, BluetoothService.Handsfree);:
System.Net.Sockets.SocketException: 'A socket operation failed because the destination host was down'
With cli.Connect(device.DeviceAddress, BluetoothService.SerialPort);it connects (so the host it is not down) but i do not get any reply from the stream.ReadAsync call.
How can i do this? Thanks!
I've found another attempt to implement this: https://github.com/SpartanX1/bluetooth_classic_battery_windows
In the README it says that device should be paired but disconnected. This way when you run the code, socket is able to connect and send/read AT reports. And device is switched to connected state automatically. This works but is absolutely insane.
If device is already connected, socket returns same error (destination host was down).
i have a question about windows 10 iot and the SPI communication. I try to communicate with an extension board for the Raspberry PI. To communicate with the board i use SPI0. The 1st slave is on GPIO 7 (Pin 26), the 2nd Chip Select is on GPIO 24 (Pin 18) and the 3rd is on GPIO 08 (Pin 24).
The Position from the Pins is fixed by the manufacturer, the system is originally for linux.
The communication with slave 1 (CS1) works very well. But that's all. My problem is to speak with the 2nd and 3rd Slave. I tryed to use the GPIO 24 as an Input/Output GPIO to set up the communication before Read from CS0 as an dummy but no chance.
At the moment, I am using a hardware hack. I am connecting PIN 18 to PIN 24 with a cable, however, I don't want to open each system to place a cable bridge.
Is there a possibility to setup an customized windows 10 iot image for the raspberry pi to use the Pin 26 as CS0, Pin 24 as CS1 and Pin 18 as CS2 ?
As #Rita Han points out, the on-board SPI controller does not support pin 18 multiplexing for SPI chip select. However, I think it's still quite possible using the Pin 18 as the CS pin if you hack the spi driver a little bit.
So the inbox SPI driver is located in here, https://github.com/ms-iot/bsp/tree/master/drivers/spi/bcm2836, if you look at the source code, you can see before and after every SPI data transfer, it's setting up the SPI register to toggle the chip select pin.
So what you can do in here is instead of using the default on-board spi driver, try using the GPIO controller to toggle the pin 18 voltage, in the inbox SPI driver.
The SPI chip select pin has slack timing requirement, so i think it should be OK to use the GPIO timing.
After which, you'll need to follow some tutorial to create custom windows iot image.
You just have to indicate the device to which you are calling.
First, set the configuration of the SPI for example, using chip select line 0
settings = new SpiConnectionSettings(0); //chip select line 0
settings.ClockFrequency = 1000000;
settings.Mode = SpiMode.Mode0;
String spiDeviceSelector = SpiDevice.GetDeviceSelector();
devices = await DeviceInformation.FindAllAsync(spiDeviceSelector);
_spi1 = await SpiDevice.FromIdAsync(devices[0].Id, settings);
You can not use this pin in further actions! So now you should configure the output ports using GpioPin class, which you will use to indicate the device.
GpioPin_19 = IoController.OpenPin(19);
GpioPin_19.Write(GpioPinValue.High);
GpioPin_19.SetDriveMode(GpioPinDriveMode.Output);
GpioPin_26 = IoController.OpenPin(26);
GpioPin_26.Write(GpioPinValue.High);
GpioPin_26.SetDriveMode(GpioPinDriveMode.Output);
GpioPin_13 = IoController.OpenPin(13);
GpioPin_13.Write(GpioPinValue.High);
GpioPin_13.SetDriveMode(GpioPinDriveMode.Output);
Always before transfer indicate device: (example method)
private byte[] TransferSpi(byte[] writeBuffer, byte ChipNo)
{
var readBuffer = new byte[writeBuffer.Length];
if (ChipNo == 1) GpioPin_19.Write(GpioPinValue.Low);
if (ChipNo == 2) GpioPin_26.Write(GpioPinValue.Low);
if (ChipNo == 3) GpioPin_13.Write(GpioPinValue.Low);
_spi1.TransferFullDuplex(writeBuffer, readBuffer);
if (ChipNo == 1) GpioPin_19.Write(GpioPinValue.High);
if (ChipNo == 2) GpioPin_26.Write(GpioPinValue.High);
if (ChipNo == 3) GpioPin_13.Write(GpioPinValue.High);
return readBuffer;
}
As a deployment test, I created a bare-bones C# Mono project in MonoDevelop. It only shows a window. I didn't make any changes to the code after creation.
It installs and runs perfectly fine on Mountain Lion.
When I install and run it on Lion, however, I get the following error:
Process: launchd [329] Path:
/Applications/Test.app/Contents/MacOS/Test Identifier:
com.yourcompany.test Version: ??? (???) Code Type: X86
(Native) Parent Process: launchd [281]
Date/Time: 2013-06-06 16:00:51.919 -0700 OS Version: Mac OS
X 10.7.5 (11G63) Report Version: 9
Interval Since Last Report: 124001 sec Crashes Since Last
Report: 28 Per-App Crashes Since Last Report: 28 Anonymous
UUID: 1AB061C0-779D-43EC-B6D3-E8C6AED2969C
Crashed Thread: Unknown
Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes:
KERN_INVALID_ADDRESS at 0x000000008fe01030
Backtrace not available
Unknown thread crashed with X86 Thread State (32-bit): eax:
0x00000000 ebx: 0x00000000 ecx: 0x00000000 edx: 0x00000000 edi:
0x00000000 esi: 0x00000000 ebp: 0x00000000 esp: 0x00000000 ss:
0x00000023 efl: 0x00010202 eip: 0x8fe01030 cs: 0x0000001b ds:
0x00000023 es: 0x00000023 fs: 0x00000000 gs: 0x00000000 cr2:
0x8fe01030 Logical CPU: 2
Binary images description not available
External Modification Summary: Calls made by other processes
targeting this process:
task_for_pid: 1
thread_create: 0
thread_set_state: 0 Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0 Calls made by all processes on this machine:
task_for_pid: 113
thread_create: 0
thread_set_state: 0
Model: iMac12,1, BootROM IM121.0047.B1E, 4 processors, Intel Core i7,
2.8 GHz, 8 GB, SMC 1.71f22 Graphics: AMD Radeon HD 6770M, AMD Radeon HD 6770M, PCIe, 512 MB Memory Module: BANK 0/DIMM0, 4 GB, DDR3, 1333
MHz, 0x80AD, 0x484D54333531533642465238432D48392020 Memory Module:
BANK 1/DIMM0, 4 GB, DDR3, 1333 MHz, 0x80AD,
0x484D54333531533642465238432D48392020 AirPort:
spairport_wireless_card_type_airport_extreme (0x168C, 0x9A), Atheros
9380: 4.0.67.5-P2P Bluetooth: Version 4.0.8f17, 2 service, 18 devices,
1 incoming serial ports Network Service: Ethernet, Ethernet, en0
Network Service: Wi-Fi, AirPort, en1 Serial ATA Device: ST31000528AS,
1 TB Serial ATA Device: HL-DT-STDVDRW GA32N USB Device: FaceTime HD
Camera (Built-in), apple_vendor_id, 0x850b, 0xfa200000 / 3 USB Device:
hub_device, 0x0424 (SMSC), 0x2514, 0xfa100000 / 2 USB Device: Dell
USB Mouse, 0x413c (Dell Inc.), 0x3200, 0xfa120000 / 5 USB Device:
BRCM2046 Hub, 0x0a5c (Broadcom Corp.), 0x4500, 0xfa110000 / 4 USB
Device: Bluetooth USB Host Controller, apple_vendor_id, 0x8215,
0xfa111000 / 7 USB Device: hub_device, 0x0424 (SMSC), 0x2514,
0xfd100000 / 2 USB Device: IR Receiver, apple_vendor_id, 0x8242,
0xfd120000 / 4 USB Device: Internal Memory Card Reader,
apple_vendor_id, 0x8403, 0xfd110000 / 3
Any thoughts? As mentioned, everything works fine on Mountain Lion.
I've tested multiple Mountain Lion computers (works fine) and multiple Lion computers (all fail).
Thanks very much
This might be a problem of where you built it: try building it in Lion instead to see if that makes a difference. I've seen problems before when trying to execute a program on an older OS than where it was built.
I'd call Ingenico's tech support, but I don't have a month to wait for their callback.
Our app uses the 6550 and it displays all the forms just fine except, on one machine it's not showing the signature box on the signature capture form. It shows the buttons and text just fine.
I've tried using our app, I've tried the Ingenico test app. Everything seems to check out fine. The only thing I get in th log is this:
2/17/2011 8:43:33 AM (31813 ms) EC0000 Device name [Ing6XXX] - UPOS-Interface-App error code=0xFD
It's followed by these lines after I dismiss the form:
2/17/2011 8:43:33 AM (31860 ms) EC0000 Device name [Ing6XXX] - Last platform error code from device=0x2, desc=SingleButtonEntry: ssaSecFuncKe
2/17/2011 8:43:33 AM (31860 ms) EC0111 Device name [Ing6XXX] - SIG - Direct IO - Command 12 - Invalid command, or function code missing. Length 5 [Package {00 05 95 FD 6D}] [Translation {iDataLength 0}{ucFunctionCode 95}{ucResponseCode FD}{ucResultCode 6D}{sData }]
2/17/2011 8:43:33 AM (31860 ms) EC0111 Device name [Ing6XXX] - SO APP - Direct IO - Command 12 - Invalid command, or function code missing. Length 5 [Package {00 05 95 FD 6D}] [Translation {iDataLength 0}{ucFunctionCode 95}{ucResponseCode FD}{ucResultCode 6D}{sData }]
I'm not sure if that's related. Does anyone have experience with these things. Any idea what might cause the failure to display the signature box?
The problem turned out to be a missing registry setting for the form location. Not sure how we missed that.