Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I am trying to read an external button interrupt in Telosb. I am using GIO2 to read the interrupt, and it works quite nice with polling techniques, but I am looking something closer to an actual interrupt method.
Referring to TinyOS, there was a HplMsp430Interrupt interface that one could implement for that purpose. I cannot find something similar in Contiki-OS.
Changing pin status does not seem to fire any events, as PROCESS_WAIT_EVENTdoes not respond.
A driver for the button on TelosB is already implemented in Contiki. There is no need to work at the interrupt handler level to use it, just call the Contiki API:
#include "dev/button-sensor.h"
PROCESS_THREAD(app_Process, ev, data)
{
PROCESS_BEGIN();
SENSORS_ACTIVATE(button_sensor);
for(;;) {
PROCESS_WAIT_EVENT();
if (ev == sensors_event && data == &button_sensor) {
puts("button clicked");
}
}
}
If you're talking about something else and actually need to implement you own interrupt handler, then Contiki will not help you much. For some Contiki platforms there are macros or functions for controlling GPIO pins, but not for msp430. So you just need to use the I/O port interface from the compiler headers, and declare interrupt handler functions with ISR(PORT_NUMBER, function_name), where PORT_NUMBER is PORT1 or PORT2 (a port that supports interrupt handlers).
See contiki/cpu/msp430/button.c for an example how the TelosB button interrupt handler is implemented, it's pretty simple.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
not sure if this is the right place to ask such a question - if not, perhaps you can direct me to the right place?
I've recently purchased a walking treadmill for my standing desk. It has a standalone control panel, connected to the base via an exposed LAN port. The panel has a few drawbacks (it's huge, has awkward and noisy buttons, no pause/return) and I wonder if I could write something very simple to control the treadmill from my PC instead. I imagine I'd need an ethernet splitter and something for network snooping to see the payload from button clicks? I've never done anything like this, so any pointers would be much appreciated. Thanks all!
1st: Be sure that the port is a compliant ethernet port to avoid damage of your equipment.
A cheap setup to analyze traffic between two devices is the use of a ethernethub or a switch which can be configured to broadcast all trafic and a pc with an ethernetsniffer. An alterntive to an hub could be two bridged ethernetcards on a pc.
A common, free and feature rich sniffer is whireshark.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I'd like to capture the traffic sent by a Sonos speaker (to troubleshoot streaming issues).
I've found one way to do this but it's a bit cumbersome: I plug the Sonos speaker via an ethernet to usb adapter to my PC, share the PC connection and then capture on that interface.
It's limited to one speaker and if the speaker has ever been configured to use the WiFi, it seems that it uses WiFi even plugged that way (and I don't capture anything).
What's the detailed setup to use port mirorring to do this? I'd like to compare the two solutions and don't know much about port mirorring setup.
Thanks!
I would recommend getting yourself a network hub to plug Sonos and the computer into and capture from that.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am novice to freeRTOS. I am currently working on a project that uses cerebot Mx7ck(PIC32) running freeRTOS. I need to read buttons using some events(i.e using button input as input event)? But I am not allowed to use polling technique or ISR available in freeRTOS.
Professor suggested to use event handler. I do not know anything about event management in freeRTOS. It looks like there is no event handler and management in freeRTOS without using interrupt service routines.
Please help. I got stuck in this for quite a while.
Configure the button to generate an interrupt.
Write an interrupt handler as described on the documentation page for the FreeRTOS PIC32 port (see the "interrupt service routines" section on the following page: http://www.freertos.org/port_PIC32_MIPS_MK4.html )
Have the interrupt service routine do whatever you want to happen when the button is pushed.
If you want the interrupt to unblock a task then you can use a task notification as demonstrated on this page: http://www.freertos.org/RTOS-task-notifications.html or more precisely http://www.freertos.org/RTOS_Task_Notification_As_Binary_Semaphore.html
If you are not using a version of FreeRTOS that supports task notifications then you can use a binary semaphore instead - that is documented also on the FreeRTOS.org website.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
My question behave to my children age, when I got a new game to play, and was very impressed.
The game was able to see and react to more than 4,6 sometimes 8 keys pressed at same time. How is this possible? There is a limit for this? Or if I press "a,s,d,f,u,v,shift,0,uparrow,rightcltr,return and backspace" all thogheter, a program can "read it"? Some introduction about it (in C, bashscript, javascript, or phyton) will be highly appreciated. Thanks for any effort here.
If we are speaking about Windows, GetKeyboardState() copies the status of the 256 virtual keys to the specified buffer.
BYTE keys[256];
if(GetKeyboardState(keys))
{
//check if A key is pressed
if((keys[VK_A]&0xF0) && !(prevKeys[VK_A]&0xF0))
{
DoAPressed();
}
//check if S key is pressed too
if((keys[VK_S]&0xF0) && !(prevKeys[VK_S]&0xF0))
{
DoSPressed();
}
// the same goes for all keys you want to check
}
You can certainly react to multiple simultaneous keypresses by tracking events that occur when keys are pressed down and separate events that occur when keys are released. For example, in X11 these events are KeyPress and KeyRelease, and in web browsers they are KeyDown and KeyUp Javascript events. But I think you will find that most keyboards have a physical limitation on how many keypresses can be electrically detected at the same time, so your example "a,s,d,f,u,v,shift,0,uparrow,rightcltr,return and backspace" might be too many keys.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
Does anyone have any visual examples?
You would have to have a separate flow chart for the interrupt processing. Flowcharts are meant for showing flow of control, and interrupts, by their very nature, are a break in control flow.
Typically interrupts communicate with your "main" function (or other interrupts for that matter) through the use of "shared" global variables in C-based embedded systems. I think a sensible way to represent this in a flow chart is to use a dashed line between processing blocks where such "communications" impact program flow.
I would set up a finite state diagram that represents the normal states of control and the interrupt states; each state would be a block-level element that contained a flowcharty kind of diagram.
Depending on flowchart structure, it would probably make most sense to have the interrupt originate from a node/box that doesn't derive from another, since, by definition, an interrupt doesn't spring from normal software flow (unless it's a software-triggered interrupt). It might make sense to have it on a separate flow chart, or to show it with the rest of the flowchart depending on whether it might trigger behavior in the main flow of the chart.
Usually, without a tasking OS or library, the interrupts just flag a variable that then effects the flow. I think #JustJeff has it right.