I have been trying for 4 days now to send the hex code 10 80 00 00 00 00 00 00 to a USB device connected to my raspberry pi running debian.
I've tried libusb with c but I have no idea what I am doing. I thought PyUSB would be a better solution but ive found zero documentation for what I need and the tutorial did'nt help.
I can find the device using
import usb.core
dev = usb.core.find(idVendor=0x12BF, idProduct=0xFF03)
But I cant find any information on how to send the above hex code. My device is a usb based relay. It works fine on windows in a vb HID application but I am struggling here. seem to be going round in circles.
Could you please tell us, how is the USB communication with the device? Is it a bulk transfer?
(see this link for more details:
http://www.beyondlogic.org/usbnutshell/usb1.shtml )
For instance, if you are using a bulk communication via an Endpoint you could try something like this (as seen here http://pyusb.sourceforge.net/docs/1.0/tutorial.html):
endpoint.write(endpointnumber, data, interfacenumber)
If you want to send a hex value, let's say 0xFF via the endpoint 2, interface 0, try something like:
endpoint.write(2, '\xFF', 0)
I hope this helps...
Related
I'm trying to read data from a "MIFARE Classic 4K - emulated (6212 Classic), Nokia" card with an ACS ACR122U reader.
The sector I need to read is number 18, the Key A is A0A1A2A3A4A5 (I can read it with my smartphone).
Nonetheless, I cannot load the key to the reader nor authenticate.
I managed to get the UID, the reader and the ATR. But I'm mysing something when I try to read a sector.
Edit: I managed to read another card with the same code (but another key). With that card I receive 90 00 with the right key, and 63 00 with a wrong one. But with this card... nothing.
Edit 2:
As far as I have read, it may be a problem with automatic protocol activation. How can I set the layer to read MIFARE Classic memory area?
I have an infrared thermometer which operates on a virtual serial port over USB, which I am trying to use on a Linux intel and next on a raspberry Pi. The system did not enumerate a /dev/ttyUSB device.
I found a piece of a solution here :
Cygnal Integrated Products serial port on Linux
I reprogrammed the product_ID and can now see it as /dev/ttyUSB0.
But trying to talk to the thermometer with minicom doesn't work.
minicom keeps saying "disconnected" despite the "9600 8N1" indication.
I must say, I had many attempt to work with this kind of communication over USB/serial adapter trying using many different terminal emulator like screen or minicom but without any success at all !
I'm not even sure about the right way to send request and receive data.
Here is the documentation I'm using trying to talk to the thermometer :
http://www.optris.com/interfaces?file=tl_files/downloads/Manuals/addendums-de-en/ct-ctlaser-commands.pdf
Edit :
I'm now trying to use PySerial Python library in a Python script with an Arduino as a target (to act as my thermometer, the arduino runs a simple code that takes the data received and send them back to my Python console.) But still, there is so many confusion possible between ASCII, Hexa, binary, that I'm not capable of debugging anything as I don't know where the transformation between different format takes place !
The communication is working as I can get some data forth and back from my Python console through the Arduino. But I can't get sending hexadecimal data and getting any response back in hexadecimal format. + You say "Your latest question puts you in the off-topic category. ", what do you mean ? Sorry of being so confused.
I'm using PIC18F87J11 as the master and LiPower Shield as the slave, and all I want to do is to be able to read the battery voltage value from the LiPower Shield. I'm using MPLAB C18 libraries for the I2C communication. I'm not able to get correct readings as I think the communication between the two devices is not setup correctly.
I'm looking for interpretations of the waveform signals in order to detect the issue. Also I would like to know if I'm missing something in the code. Any recommendations to improve the code would be helpful.
The LiPower Shield came with a sample code for Arduino but I'm using PIC18 chip from Microchip. The sample code is found here.
Here is the signals I'm getting while trying to read the battery voltage.
Code:
SSP2ADD = 19;
OpenI2C2(MASTER,SLEW_OFF);
StartI2C2();
IdleI2C2();
WriteI2C2(0x36);
IdleI2C2();
data = ReadI2C2(); // Read byte of data
printf ("\r\nAddress 32");
printf (" Byte:");
PrintChar(data);
IdleI2C2();
AckI2C2();
IdleI2C2();
WriteI2C2(0x02);
IdleI2C2();
data = ReadI2C2(); // Read byte of data
printf ("\r\nAddress 02");
printf (" Byte:");
PrintChar(data);
IdleI2C2();
AckI2C2();
StopI2C2(); // Stop condition I2C on bus
Output: Which I think is wrong.
Address 32 Byte:FF
Address 02 Byte:FF
I'm not really sure if I'm writing/reading from the correct address, but that's the address they used in the their sample code. I hope I can get some interpretations on the signals and feedback on the code if possible.
I'm not familiar with the PIC but your code looks nowhere near right. Per the MAX17043DS datasheet, page 12, a memory read must consist of the following:
I2C start condition
Write device I2C write address (0x6C)
Check for ACK from slave
Write 8-bit memory address
Check for ACK from slave
I2C repeated start condition
Write device I2C read address (0x6D)
Read first byte of data
Send ACK
Read second byte of data
Send NACK
I2C Stop condition
What I see in your code is an I2C Start condition followed by a write 0f 0x36. Since this is not the device address the slave recognizes, it sends a NACK (as seen on your logic analyzer traces) and ignores everything else.
This question and answer has a lot of information on I2C on a PIC18. You also should probably find a read a basic I2C tutorial.
I'm currently working on a c project, having an XBee Pro Series 1 on my pc, allowing me to send data to my nibo2 roboter, also having that xbee module attached.
Sending data from the nibo2 roboter to my pc works great and there is no kind of data loss.
Sending data from my pc to the nibo2 works not fine:
When I'm trying to send 16 Bytes at one point of time, only the first 8 Byte arrive at my nibo2. The second 8 Byte are lost. When i send the data split into 8 Bytes and send them with a time difference of maybe 1s - 2s, it works fine.
The maybe interesting things you should know about this, are listed here:
XBee Datasheet: http://ftp1.digi.com/support/documentation/90000982_H.pdf
The used library for the roboter (using uart0): http://nibo.sourceforge.net/doc/html/
Does anyone have an idea or does someone know the problem? Is it a thing about configuring the xbee module? interrupt problem?
Thanks a lot.
How have you configured the XBee modules? Which firmware version? What baudrate? Are you using hardware flow control (CTS and RTS signals)?
Can you use the "Assemble Packet" button on Terminal tab of X-CTU on the PC to send the 16-byte packet and have it received properly?
Can the serial port of the NIBO2 handle 16 bytes in one request? Does it work if you use a wired connection instead of wireless?
I'd like to start coding against an ELM327 based automotive OBD-II Bluetooth adapter in iOS/Objective-C. Is there a guide/primer on how to get started?
I would imagine the ELM327 adapter is a serial device... I can probably figure out how to establish a Bluetooth connection with the phone, but I haven't any idea where to start with sending/receiving OBD-II messages to/from it.
Is there a pre-existing API for this device?
If you need some OBDKey specific commands let me know. As an example, to access the RPM data, issue the following commands
ATZ\r
ATSP0\r
0100\r
010C\r
These instructions will initialise the OBDKey interface, set the protocol search on to automatic, initialise communcations with the engine managment ECU and send the mode 1 PID 0C command to request engine speed (RPM) data. The value returned in response to the 010C command is actually four time the real engine speed value.
Using sockets and streams in iOS / Objective-C is the best way to set up communications to the OBDKey WLAN (the default IP address is 192.168.0.74, port 23).
The elm327 odb2 device uses AT and ODB commands.
The AT commands are the same as you use on modems, they always start with AT.
When the devices initializes it sends
ELM327 v2.1
>
If you send
ATZ
this will reset device and it will issue "ELM327 v2.1" and > prompt again.
AT commands are used to manage the elm327 device.
ODB commands are in asci hex such as the above example
01 0c
to get the rpm or
01 05
to get coolant temp
At http://www.elmelectronics.com/obdic.html there are data sheet pdf files with more details.
Also you can search ituns for "elm327" and get 2 free books on the subject.
I'm just starting the same project for my generic elm327 wifi device so I dont have any details yet.
I will add comments as soon as I learn anything useful.