I'm developing an HID Host application to comunicate with a own device and I'm using the NUCLEO-F446ZE board.
At the start I tried to use the HID_Standalone application in the STM32CubeF4 firmware package and then, I tried to develop a new application with STMCube configurator.
In both case I tried to connect (with OTG connector) 3 different type of mouse and 1 keyboard and no all device are able to comunicate with microcontroller:
with Typhoon mouse 40260 the USBH_Process state machine in the usbh_core.c file of the Middlewares, blocks in the HOST_ENUMERATION state (line 462) because the USBH_HandleEnum(phost) function try to get device descriptior (line 646 same file) but the USBH_HandleControl() function read all times USBH_URB_NOTREADY state (line 600 of usbh_ctlreq.c) until HAL_HCD_Disconnect_Callback() called by interrupt.
with Trust mouse 16144 is the same with Typhoon mouse with difference that the HAL_HCD_Disconnect_Callback() isn't called by interrupt.
with Dell Mouse XN966 all work fine and I can see the data.
with asus keyboard G01 KB the USBH_Process state machine in the usbh_core.c come up to HOST_DEV_DISCONNECTED where there is the BgndProcess but I can't receive data because in the HID_Handle the fifo has the tail and head at the same value.
All the previous devices are tested with PC and work fine and the board are powerd with external source.
What can be the problem and how can I fix it?
Thanks in advance
Related
I am using a board with AT91SAM9G45C processor, booting from an SD-card. That works. Now i extended the software with a filetransfer function, to upload a new application software to the SD-card. This part also works.
My problem is, if i create a reset on the controller (watchdog or ResetController)
AT91C_BASE_RSTC->RSTC_RCR = AT91C_RSTC_KEY | AT91C_RSTC_PERRST | AT91C_RSTC_PROCRST;
while(AT91C_BASE_RSTC->RSTC_RSR & AT91C_RSTC_SRCMP);
//Jump to the reset vector
(*(void(*)())0)();
, the controller starts only the programm in RAM (initialisation, ...) but dont load the new programm from SD-card. Only after a reset with power-supply off, the controller reloads the programm from SD-card.
My question: how can a software-reset created that reloads the programm new from the SD-card?
can someone help me?
Fritz
I've been trying for a couple of days now, to create a simple DMA program for the G4. But without HAL (using libopencm3). The goal is to configure DMA to read data (in circular mode) from buffer and send them to TIM17_CCR1. I've made the code work in HAL previously, but have no luck with libopencm3. I've managed to transfer data from buffer to the OCR in mem2mem mode (even though i need mem2perif) just to try. But I have no idea on how to start with mem2perif. Configuring DMA is no big deal, but I'm lost in the DMAMUX part.
Do you even have to configure it? How do you configure it the right way? I'm totally lost in ST's documentation and can't find any existing code using DMAMUX without HAL.
Do any of you have any examples I could look at? Best would be some bare metal C so I could check out the registers. Anything that would help some documents (else than STs own)? It would be much appreciated.
Thanks a lot!
I've got it working even with the library, just needed one more day of testing :(
Here is the code for anybody interesrted:
gpio_mode_setup(GPIOB, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO_FRONT_LED | GPIO_BACK_LED);
gpio_set_output_options(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_FRONT_LED | GPIO_BACK_LED);
gpio_set_af(GPIOB, GPIO_AF10, GPIO_BACK_LED);
//Setup for back led
dma_set_priority(DMA1, DMA_CHANNEL1, DMA_CCR_PL_LOW);
dma_set_memory_size(DMA1, DMA_CHANNEL1, DMA_CCR_MSIZE_8BIT);
dma_set_peripheral_size(DMA1, DMA_CHANNEL1, DMA_CCR_PSIZE_16BIT);
dma_enable_memory_increment_mode(DMA1, DMA_CHANNEL1);
dma_enable_circular_mode(DMA1, DMA_CHANNEL1);
dma_set_read_from_memory(DMA1, DMA_CHANNEL1);
dmamux_set_dma_channel_request(DMAMUX1, DMA_CHANNEL1, DMAMUX_CxCR_DMAREQ_ID_TIM17_CH1);
dma_set_peripheral_address(DMA1, DMA_CHANNEL1, (uint32_t)&TIM17_CCR1);
dma_set_memory_address(DMA1, DMA_CHANNEL1, (uint32_t)&ledBackBuffer);
dma_set_number_of_data(DMA1, DMA_CHANNEL1, LED_BACK_BUFFER_SIZE);
timer_enable_preload(TIM17);
timer_update_on_overflow(TIM17);
timer_set_dma_on_update_event(TIM17);
timer_enable_irq(TIM17, TIM_DIER_CC1DE);
timer_generate_event(TIM17, TIM_EGR_CC1G);
timer_set_oc_mode(TIM17, TIM_OC1, TIM_OCM_PWM1);
timer_enable_oc_output(TIM17, TIM_OC1);
timer_enable_break_main_output(TIM17);
timer_set_period(TIM17, 179);
timer_enable_counter(TIM17);
dma_enable_channel(DMA1, DMA_CHANNEL1);
ledBackBuffer is basic uint8_t array filled with data to be transmitted to all the LEDs.
I try to run an example script from dronekit. the code is looks like this :
import gps
import socket
import time
from droneapi.lib import VehicleMode, Location
def followme():
"""
followme - A DroneAPI example
This is a somewhat more 'meaty' example on how to use the DroneAPI. It uses the
python gps package to read positions from the GPS attached to your laptop an
every two seconds it sends a new goto command to the vehicle.
To use this example:
* Run mavproxy.py with the correct options to connect to your vehicle
* module load api
* api start <path-to-follow_me.py>
When you want to stop follow-me, either change vehicle modes from your RC
transmitter or type "api stop".
"""
try:
# First get an instance of the API endpoint (the connect via web case will be similar)
api = local_connect()
# Now get our vehicle (we assume the user is trying to control the first vehicle attached to the GCS)
v = api.get_vehicles()[0]
# Don't let the user try to fly while the board is still booting
if v.mode.name == "INITIALISING":
print "Vehicle still booting, try again later"
return
cmds = v.commands
is_guided = False # Have we sent at least one destination point?
# Use the python gps package to access the laptop GPS
gpsd = gps.gps(mode=gps.WATCH_ENABLE)
while not api.exit:
# This is necessary to read the GPS state from the laptop
gpsd.next()
if is_guided and v.mode.name != "GUIDED":
print "User has changed flight modes - aborting follow-me"
break
# Once we have a valid location (see gpsd documentation) we can start moving our vehicle around
if (gpsd.valid & gps.LATLON_SET) != 0:
altitude = 30 # in meters
dest = Location(gpsd.fix.latitude, gpsd.fix.longitude, altitude, is_relative=True)
print "Going to: %s" % dest
# A better implementation would only send new waypoints if the position had changed significantly
cmds.goto(dest)
is_guided = True
v.flush()
# Send a new target every two seconds
# For a complete implementation of follow me you'd want adjust this delay
time.sleep(2)
except socket.error:
print "Error: gpsd service does not seem to be running, plug in USB GPS or run run-fake-gps.sh"
followme()
I try to run it in my Raspberry with Raspbian OS, but i got an error message like this :
Error : gpsd service does not seem to be running, plug in USB GPS or run run-fake-gps.sh
I get a feeling that my raspberry is needed a gps kind of device to be attached before i can run this script, but i dont really know.
Please kindly tell me whats wrong with it..
the full path of instruction i got from here :
http://python.dronekit.io/1.5.0/examples/follow_me.html
As the example says:
[This example] will use a USB GPS attached to your laptop to have the vehicle follow you as you walk around a field.
Without a GPS device, the code doesn't know where you are so it would not be possible to implement any sort of "following" behavior. Before running the example, you would need to:
Acquire some sort of GPS device (I use one of these, but there are lots of alternatives).
Configure gpsd on your laptop to interface with the GPS device.
Ok what the heck is up with iOS6 and how it handles Bluetooth LE disconnections? Before the device would disconnect immediately but now, for some strange reason, the device waits to disconnect for about 30-60 seconds. I need it to disconnect ASAFP!
I've been searing all over the internet trying to figure out how to initiate an immediate disconnection from the peripheral and I found this nifty email that explains a workaround is to unsubscribe from notifications on the service characteristics.
Now I think I'm doing that.. When I want to disconnect I call [connected_device setNotifyValue:NO forCharacteristic:connected_characteristic]
Then, in the didUpdateNotificationStateForCharacteristic function, I have...
if((int)characteristic.isNotifying == 0){
[manager cancelPeripheralConnection:peripheral];
}
In the function didDisconnectPeripheral...
connected_peripheral = nil;
connected_characteristic = nil;
[connected_peripheral release];
[connected_characteristic release];
I've also taken a good hard look at Apple's CoreBluetooth Temperature Sensor example but it hasn't really helped much....
Any help on this would be amazing!! I just don't know what I'm missing.....
UPDATE: It looks like the app needs to be connected to the bluetooth device for at least a minute before it is allowed to disconnect. If the app is connected for over a minute it will disconnect immediately when the command is sent. Otherwise, it will wait until that one minute mark to actually disconnect.
UPDATE: When I try to disconnect before the one minute mark, I get the following output to the log when the device actually disconnects.
Oct 24 16:49:35 Christophers-iPhone awdd[8168] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Oct 24 16:49:35 Christophers-iPhone awdd[8168] <Error>: CoreLocation: CLClient is deprecated. Will be obsolete soon.
According to Apple, this new feature is "by design".
The way we resolved this issue was to send a command to the Peripheral and have it disconnect from its end. If you do this, then the disconnect is immediate. I do not know why Apple changed this behavior from iOS5 to iOS6 but they must have had their reasons. Of course this solution only works if you have access to the Peripheral firmware and can change it. If there is a different solution, then we have not found it.
That was a bug in iOS 6.0, in 6.1 it's fixed.
We are working on a C language application which is simple RTSP/RTP client to record video from Axis a number of Cameras. We launch a pthread for each of the camera which establishes the RTP session and begin to record the packets captured using the recvfrom() call.
A single camera single pthread records fine for well over a day without issues.
But testing with more cameras available,about 25(so 25 pthreads), the recording to file goes fine for like 15 to 20 mins and then the recording just stops. The application still keeps running. Its been over a month and a half we have been trying with varied implementations but nothing seems to help. Please provide suggestions.
We are using CentOS 5 platform
Define "record" Does that mean write data to a file? How do you control access to the file?
You can't have several threads all trying to write at the exact same time. So the comment by Alon seems to be pertinent. Your write access control machanism has problems.
void *IPThread(void *ptr)
{
//Establish RTSP session
//Bind to RTP ports(video)
//Increase Socket buffer size to 625KB
record_fd=open(record_name, O_CREAT|O_RDWR|O_TRUNC, 0777);
while(1)
{
if(poll(RTP/RTCP ports)) //a timeout value of 1
{
if(RTCP event)
RTCPhandler();
if(RTP event)
{
recvfrom(); //the normal socket api recvfrom
WritePacketToFile(record_fd)
{
//Create new record_fd after 100MB
}
}
}
}
}
even if it is alright to stick to the single threaded implementation why is the multithreaded approach behaving such a way(not recording after ~15 mins)..?