User Tools

Site Tools


opus:fall2012:asowers:part2

Part 2

Entries

Entry 1: October 3, 2012

Today we figured out how to call system tasks using nothing but the asterisk extensions.conf file.

To add an extension executes a script you simply need to add “System(pathtoscript.sh)”

In practice this would look like this:

exten => 607,1,Answer
exten => 607,2,Wait(1)
exten => 607,3,System(path/to/script.sh) ;make sure to place in writable path for asterisk user
exten => 607,4,Hangup()

This opens a plethora of new possibilities that we'll explore in the coming weeks!

Entry 2: October 7, 2012

Today I've decided to start researching the implications of installing PBX and Asterisk on my Raspberry Pi. My ultimate goal would be initiating a house appliance by literally calling it through asterisk. Smart appliances here I come! =D I'm starting my research here:

UPDATE! FreePBX is loaded and I've setup some extensions. Now I'll be looking into some ip appliances for automation.

Entry 3: October 31, 2012

Finding direction in Data Com

With everyone moving into their individual projects I'm at as loss with what to do. Hoping we can establish a tangible direction some time soon.

Entry 4: October Day, 2012

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

Remember that 4 is just the minimum number of entries. Feel free to have more.

Keywords

cprog Keyword 2

Identification of chosen keyword.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • Reference 1
  • Reference 2
  • Reference 3

cprog Keyword 2 Phase 2

Identification of chosen keyword.

Arrays

Arrays are buckets or memory locations that group similar integers or character strings.

Arrays can be manipulated to hold different values of any datatype as long as that datatype is consistant across the entire array. You can even copy the contents of one array to another!

Example:

#include<stdio.h>
int main()
{
int array [5];
int i;
short onethroughfive [5];
array[0] = 45;
array[1] = 56;
array[2] = 34;
array[3] = 42;
array[4] = 32;
for(i=0; i<5; i++){
    *(onethroughfive+i)=*(array+i);
}
for (i=0; i<5; i++){
   printf("%d\n", *(onethroughfive+i));
}
return (0);
}

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • Reference 1
  • Reference 2
  • Reference 3

datacomm Keyword 2

Identification of chosen keyword.

Raspberry Pi GPIO Programming

The Raspberry Pi hosts a General Purpose Input Output board for interfacing with low level peripherals. Dragon.net was nice enough to write a detailed C library for the GPIO to make electronics programming super easy! Here's an example of a program that turns on and off an LED:

/*
 * blink.c:
 *      Simple test program to blink an LED on pin 7
 */
 
#include <wiringPi.h>
#include <stdio.h>
 
int main (void)
{
  int pin = 7;
  printf("Raspberry Pi wiringPi blink test\n");
 
  if (wiringPiSetup() == -1)
    exit (1);
 
  pinMode(pin, OUTPUT);
 
  for (;;){
    printf("LED On\n");
    digitalWrite(pin, 1);
    delay(250);
    printf("LED Off\n");
    digitalWrite(pin, 0);
    delay(250);
  }
 
  return 0;
}

by way of this reference I hope to setup a simple c application using a solid state relay for my future automated “Dial a Coffee” via Asterisk and Pi ingenuity:http://elinux.org/RPi_Low-level_peripherals#GPIO_Driving_Example_.28C.29

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

datacomm Keyword 2 Phase 2

Identification of chosen keyword.

Lair Brew

A simple program that operates a relay switch that supplies electricity for delicious caffeinated beverages.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • Tom's mom

Demonstration

/*
Lair_Brew ~ Caffeine ~
Version 0.2
*/
 
#include <wiringPi.h>
#include <stdio.h>
 
void loopback(void)
{
    char ch;
    ch = getchar();
    while( ch != '\n' ) ch = getchar();
}
 
int main (void)
{
    int pin = 7;
    char ch;
    int exit_flag = 0;
    printf("welcome to Lair Brew\n");
 
  if (wiringPiSetup() == -1) return(1);
 
    pinMode(pin, OUTPUT);
    printf("Brew on\n");
    digitalWrite(pin, 1);
 
 while( exit_flag  == 0 ) {
    printf("Wish to exit? (Y)\n");
    scanf(" %c", &ch );
    ch = toupper( ch );
 
 if((ch == 'Y')){
    printf("\nBrew Off\n");
    digitalWrite(pin, 0);
    delay(250);
    printf("\nEnjoy Your Coffee, Sir!\n");
  }
  else {
    printf("\nType (y) to exit.\n");
    loopback();
  }
   if( ch == 'Y' ) exit_flag = 1;
  }
 
  return 0;
}

The program is loaded into /etc/asterisk/extensions.conf like so:

exten => 607,1,Answer
exten => 607,2,Wait(1)
exten => 607,3,System(/tmp/Lair_brew_auto)
exten => 607,4,Hangup()

Experiment 2

Question

Can you include the main() of a program in a header file?

Resources

Collect information and resources (such as URLs of web resources), and comment on knowledge obtained that you think will provide useful background information to aid in performing the experiment.

Hypothesis

Based on what you've read with respect to your original posed question, what do you think will be the result of your experiment (ie an educated guess based on the facts known). This is done before actually performing the experiment.

State your rationale.

Experiment

How are you going to test your hypothesis? What is the structure of your experiment?

Data

Perform your experiment, and collect/document the results here.

Analysis

Based on the data collected:

  • Was your hypothesis correct?
  • Was your hypothesis not applicable?
  • Is there more going on than you originally thought? (shortcomings in hypothesis)
  • What shortcomings might there be in your experiment?
  • What shortcomings might there be in your data?

Conclusions

What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.

opus/fall2012/asowers/part2.txt · Last modified: 2012/11/01 20:31 by asowers