What is the "interfaceId" referring to in chrome.usb.findDevices() and chrome.usb.requestAccess()? - google-chrome-extension

I'm trying to get a USB device to work on ChromeOS, and I'm running into an issue. From what I understand, I need to do this for the device I'm trying to utilize:
chrome.usb.requestAccess(Device device, integer interfaceId, function callback)
or, I can use:
chrome.usb.findDevices(Device device, function callback)
Whichever one I choose, I need to provide the interfaceId (as part of the device tuple in findDevices, or as the second parameter in requestAccess)
https://developer.chrome.com/apps/usb#method-findDevices
vendorId
productId
interfaceId (The interface id to request access against. Only available on ChromeOS. It has no effect on other platforms.)
I cannot find any documentation regarding this anywhere -- and nothing I try seems to work.

I was confused too and then I found the answer in the specifications of the function:
integer (optional) interfaceId
Since Chrome 29. The interface ID to request access to. Only available on Chrome OS. It has no effect on other platforms.
Referred to: https://developer.chrome.com/apps/usb#method-findDevices

Related

Best way to validate DICOM connection request with pynetdicom

What is the preferred way to validate requested DICOM connection against a list of known hosts?
I can connect to the EVT_CONN_OPEN event. But in that, the event.assoc.requestor.info.ae_title element is always empty (b'').
I see from a TCP network analysis, that the name is transmitted. So, where is it?
What is the right way to validate the requesting host?
You could try using EVT_REQUESTED instead, it gets triggered after an association request is received/sent and the AE title information should be available at that point. Unfortunately EVT_CONN_OPEN is triggered on TCP connection which occurs prior to the association request.
If you don't like the host's details you can use the handler to send an association rejection message using event.assoc.acse.send_reject() or abort with event.assoc.abort().
If you're only interested in validating against the AE title you can use the AE.require_calling_aet property to restrict associations to those with matching AE titles.
For the benefit of anyone else looking this up, the correct stage to look this up is in the EVT_REQUESTED event. However you will likely find the details aren't filled in (they are populated AFTER the handler has been called).
So if you want to locate the callers AE in EVT_REQUESTED, you need to locate the A_ASSOCIATE primitive and read them from there. So for example in your handler you can do this to reject remotes:
def handle_request(event):
req_title = event.assoc.requestor.primitive.calling_ae_title.decode('ascii')
if req_title != 'MyAET':
event.assoc.acse.send_reject(0x01, 0x01, 0x03)
return
At least for 1.5.7.

Stripe: Getting Credit Card's Last 4 Digits

I have upgraded the Stripe.net to the latest version which is 20.3.0 and now I don't seem to find the .Last4 for the credit card. I had the following method:
public void CreateLocalCustomer(Stripe.Customer stipeCustomer)
{
var newCustomer = new Data.Models.Customer
{
Email = stipeCustomer.Email,
StripeCustomerId = stipeCustomer.Id,
CardLast4 = stipeCustomer.Sources.Data[0].Card.Last4
};
_dbService.Add(newCustomer);
_dbService.Save();
}
But now the stipeCustomer.Sources.Data[0].Card.Last4 says 'IPaymentSource' does not contain a definition for 'Card'. Does anyone know how I can get the card details now? The flow is that I create the customer by passing the Stripe token to Stripe, then I get the above stripeCustomer. So I expect it to be somewhere in that object. But I can't find it. The release notes can be found here.
Thank you.
In the old world of Stripe, there only used to be one type of payment method you could attach to a Customer; specifically, Card-objects. You would create a Card-object by using Stripe.js/v2 or the Create Token API Endpoint to first create a Token-object and then attach that token to a Customer-object with the Create Card API Endpoint.
Once Stripe expanded to support a number of other payment methods though, Stripe built support for a new object type that encapsulated a number of payment methods (including credit cards) called Source-objects. A Source-object is created either by using Stripe.js/v3 or the Create Source API Endpoint. It can also be attached to a Customer-object in much the same way as the Card-objects mentioned above, except they retain their object type. They're still a Source. You use the Attach Source API Endpoint to do this (that is notably identical to the Create Card API Endpoint mentioned above).
What I'm getting at here, is there are now two different object types (or more) that you can expect to see returned in the sources-array (or Sources in .NET). All of these methods though inherit from the IPaymentSource-interface. So if you know you have a Card-object getting returned, you can simply cast the returned object to the Card-class.
Something like this should get you going:
CardLast4 = ((Card) stipeCustomer.Sources.Data[0]).Last4
You can see what I mean by inheritance by looking at this line in the Card-class file:
https://github.com/stripe/stripe-dotnet/blob/master/src/Stripe.net/Entities/Cards/Card.cs#L7
Good luck!
As of Stripe.net.21.4.1, this is what works:
var chargeService = new ChargeService();
var charge = chargeService.Get(id);
CardLast4 = ((Card)charge.Source).Last4;
It's getting hard not to panic when code breaks because of all the micro-changes Stripe makes.
So after debugging, it looks like the Data[0] needs to be cast as Card to get the card.
So it will be CardLast4 = ((Card)stipeCustomer.Sources.Data[0]).Last4.

#SNMP No contextName in V3 response

We are using #SNMP to created an SNMP V3 agent.
I would like to know if it is normal that the SecureSnmpContext class does not use the given ContextName when using GeneratedResponse for example ?
The ContextName is available into the request object ?
In the code, OctetString.Empty is used instead of ContextName.
new Scope(Group.EngineId,
OctetString.Empty,
new ResponsePdu(
Request.RequestId(),
ErrorCode.NoError,
0,
variables)),
Is the ContextName not required in the response maybe ?
Thanks
The design of the snmpd sample follows Net-SNMP agent, which does not use the context name much.
If you have requirements to set that field, feel free to modify the code base to suit your needs please.
Remember that you also need to modify the authentication part to verify context name of the incoming messages if you do set a context name.

PlayReady SME parameters on GoogleCast

1. When using encrypted media extensions on GoogleCast, from the example code here (section 8.4)
https://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html#examples:
what should be specified for PlayReady in:
video.setMediaKeys(new MediaKeys(keySystem));
as a keySystem?
2. In the same function, there is initData var (event.initData) in function handleKeyNeeded(event). If it is extended by adding custom data, will it be preserved by the DRM engine while license request generating and if not, how to workaround it?
In answer to your first question:
video.setMediaKeys(new MediaKeys("com.microsoft.playready"));
However it would be prudent to query the what systems are supported for given media types using iTypeSupported as per:
https://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html#dom-istypesupported

device types in CreateAsyncFind function of UPnP

Please tell me what is range of values I can give in device type parameter of CreateAsyncFind() function. How it detects the devices basis on string given ???
Thanks in Advance !!!
Each UPnP device has its own unique type and URI, you will need to supply the URI in your call to CreateAsyncFind(). As an example to search for a MediaServer:3 device you would use urn:schemas-upnp-org:device:MediaServer:3.
Checkout Device Categories for a list of different device categories.

Resources