LISTSERV mailing list manager LISTSERV 16.0

Help for ROBOTICS-CLUB-L Archives


ROBOTICS-CLUB-L Archives

ROBOTICS-CLUB-L Archives


ROBOTICS-CLUB-L@LISTSERV.GMU.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

ROBOTICS-CLUB-L Home

ROBOTICS-CLUB-L Home

ROBOTICS-CLUB-L  March 2016

ROBOTICS-CLUB-L March 2016

Subject:

Signal code to shut down the robots cleanly

From:

Sean Luke <[log in to unmask]>

Reply-To:

GMU Robotics Club <[log in to unmask]>

Date:

Fri, 25 Mar 2016 16:09:14 -0400

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (39 lines)

For those of you who were running stuff on the flockbots today.  Here's some code you could toss in which will cause the robot to shut down gracefully when the user presses CONTROL-C.  It does this by intercepting the SIGINT signal (which is sent by control-C) to clean up stuff appropriately before dying. 

Sean


// Include this at the top
#include <signal.h>


// put this function somewhere in your code.
// It will be called when the user presses control-c
void handle_control_c (int s)
{
camera_forward();
robot_stop();
claw_open();
lcd_clear();
lcd_set_cursor(1,1);
lcd_write("Cancelled");
shutdown_api();  // redundant?  Dunno
exit(1);
}



int main()
{
// before anything else, say:

struct sigaction sigIntHandler;
sigIntHandler.sa_handler = handle_control_c;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);

// now put the rest of your code here

}

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

March 2020
February 2020
January 2020
December 2019
September 2019
May 2019
April 2019
March 2019
February 2019
October 2018
September 2018
January 2018
October 2017
September 2017
April 2017
January 2017
September 2016
May 2016
April 2016
March 2016
February 2016
January 2016
November 2015
October 2015
September 2015

ATOM RSS1 RSS2



LISTSERV.GMU.EDU

CataList Email List Search Powered by the LISTSERV Email List Manager