CARI Infonet

 Forgot password?
 Register

ADVERTISEMENT

View: 3871|Reply: 11

sape-sape yang teror programming nak mintak tolong!!!

[Copy link]
Post time 20-12-2010 06:20 PM | Show all posts |Read mode
salam semua, actually aku tak taw lah sama da ni thread yg betul atau tak kalo tak tolong gtaw yer, sebab aku perlukan sangat-sangat pertolongan geek-geek programming yg mantop untuk ajarkan aku buat c program untuk projek sekolah aku.
Aku nak buat satu project usb ni, pakai infrared sensor. Bila infrared sensor ni detect movement dia akan bagi output dekat komputer then dari komputer pulak nak idupkan alarm,lampu dan antar mail. Macam dari usb control alarm ngn lampu pastu anta mel melalui usb.Cikgu suruh buat pakai linux.C programing. Lepas tu kitaorg pakai usb kit dari kedai km2.net..situ dia ada bagi taw command je, cme aku taktaw cmne nak start wat program sebab programming pengetahuan aku 0.aku taktaw pape wehhhhhhhhh tolonggggg!!!!!!!!!!
Reply

Use magic Report


ADVERTISEMENT


Post time 20-12-2010 08:17 PM | Show all posts
gua xtau.gua blaja visual basic 6 je
Reply

Use magic Report

 Author| Post time 20-12-2010 09:41 PM | Show all posts
Reply 2# myralolx92


    alaaa yeke ... ni ader program contoh dari kedai tu,and aku tak paham lansung ape mksud dia,boleh tolong explainkan kalo tahu..time kaseyyy


/* For TECHNO KIT */
// #define USB_VENDOR  0x12ed
// #define USB_PRODUCT 0x1003
/* For USB-An */
#define USB_VENDOR  0x1352
#define USB_PRODUCT 0x0110
/* Init USB */
struct usb_bus *morphy_init()
{
    usb_init();
    usb_find_busses();
    usb_find_devices();
    return( usb_get_busses() );
}
/* Find Morphy-USBIO  */
struct usb_device *morphy_find(struct usb_bus *busses, struct usb_device *dev)
{
    struct usb_bus *bus;
    for(bus=busses; bus; bus=bus->next){
        for(dev=bus->devices; dev; dev=dev->next) {
            if( (dev->descriptor.idVendor==USB_VENDOR) && (dev->descriptor.idProduct==USB_PRODUCT) ){
                return( dev );
            }
        }
    }
    return( NULL );
}
/* USBIO Open */
struct usb_dev_handle *morphy_open(struct usb_device *dev)
{
    struct usb_dev_handle *udev = NULL;
    udev=usb_open(dev);
    if( (udev=usb_open(dev))==NULL ){
        printf("usb_open Error.(%s)\n",usb_strerror());
        exit(1);
    }
    if( usb_set_configuration(udev,dev->config->bConfigurationValue)<0 ){
        if( usb_detach_kernel_driver_np(udev,dev->config->interface->altsetting->bInterfaceNumber)<0 ){
            printf("usb_set_configuration Error.\n");
            printf("usb_detach_kernel_driver_np Error.(%s)\n",usb_strerror());
        }
    }
    if( usb_claim_interface(udev,dev->config->interface->altsetting->bInterfaceNumber)<0 ){
        if( usb_detach_kernel_driver_np(udev,dev->config->interface->altsetting->bInterfaceNumber)<0 ){
            printf("usb_claim_interface Error.\n");
            printf("usb_detach_kernel_driver_np Error.(%s)\n",usb_strerror());
        }                              
   
    }
    if( usb_claim_interface(udev,dev->config->interface->altsetting->bInterfaceNumber)<0 ){
        printf("usb_claim_interface Error.(%s)\n",usb_strerror());
    }
    return(udev);
}
/* USBIO Close */
void morphy_close(struct usb_dev_handle *udev)
{
    if( usb_close(udev)<0 ){
        printf("usb_close Error.(%s)\n",usb_strerror());
    }
}
/* USBIO out */
void uio_out(struct usb_dev_handle *udev, int PortNo, int OutData)
{
    unsigned char ctl[64]; //8-> 64
    ctl[0]=0x01+(PortNo&1);
    ctl[1]=OutData;
    ctl[2]=ctl[3]=ctl[4]=ctl[5]=ctl[6]=ctl[7]=0;
    usb_control_msg(udev,0x21,0x09,0x00,0x00,ctl,64,5000); //8-> 64

}
/* USBIO in*/
int uio_in(struct usb_dev_handle *udev, int PortNo )
{
    int i,ret;
    unsigned char ctl[64];  //8-> 64
    unsigned char indat[64]; //8-> 64
    static n=0;
    n++;
    /* CMD:Read */
    ctl[0]=0x03+(PortNo&1);
    ctl[1]=ctl[2]=ctl[3]=ctl[4]=ctl[5]=ctl[6]=0;
    ctl[7]=n;
    ret=usb_control_msg(udev,0x21,0x09,0x00,0x00,ctl,64,5000); //8-> 64
    if( ret<0 ){
        printf("Read-CmdError\n");
        return (-1);
    }
    i=0;
    do {
        ret=usb_interrupt_read(udev,1,indat,64,5000); //8-> 64
        if( ret<0 ){
            printf("Int-Read Error\n");
            return (-2);
        }
        if (++i>100){
            printf("Int-Read Error\n");
            return (-3);
        }
    }while (ctl[7]!=indat[7]);
    //ret=usb_interrupt_read(udev,1,indat,8,5000);  //DEL
    return (indat[1]);
}
/* fsio_io */
int fsio_io(struct usb_dev_handle *udev, unsigned char *outData, unsigned char *inData)
{
    int ret;
        // ret=usb_control_msg(udev,0x01,0x09,0x00,0x00,outData,64,5000);
    ret = usb_bulk_write(udev, 1, outData, 64, 5000); //
       // ret=usb_interrupt_read(udev,1,inData,64,1000);
     if( ret < 0 ){
        printf("Read-CmdError\n");
              return(-1);
    }
      //ret=usb_interrupt_read(udev,1,inData,64,1000);
     ret = usb_bulk_read(udev, 1, inData, 64, 5000);
      if( ret < 0 ){
               printf("Int-Read Error:%d\n", ret);
            return(-2);
        }


}
int fsio_ai(struct usb_dev_handle *udev, float *voltage)
{
    int ret, i;
    unsigned char uin[64];
    unsigned char ctl[64] =  {0x2A,0x01,0x00,0x00,
     0x02,0x00,0x00,0x03,
     0x00,0x00,0x04,0x00,
     0x00,0x05,0x00,0x00,
     0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,
                                 0x00,0x00,0x00,0x00,
                                 0x00,0x00,0x00,0x00,
                                 0x00,0x00,0x00,0x00,
                                 0x00,0x00,0x00,0x00,
                                 0x00,0x00,0x00,0x00,
                                 0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x05};
        ret = usb_bulk_write(udev, 1, ctl, 64, 5000);
    if( ret < 0 ){
        printf("Read-CmdError\n");
              return(-1);
    }
     ret = usb_bulk_read(udev, 1, uin, 64, 5000);
      if( ret < 0 ){
               printf("Int-Read Error:%d\n", ret);
            return(-2);
        }
     for(i = 0; i <= 5; i++){  
  voltage = (float)(uin[3]*256 + uin[2] ) * 5000 / 1023;
printf("%x;%x;%f\n",uin[3],uin[2],voltage);
}
  return(1);


}
int fsio_rom_read(struct usb_dev_handle *udev, unsigned char *uin)
{
    int ret, i;

    unsigned char ctl[64] =  {0xF8,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,
                                 0x00,0x00,0x00,0x00,
                                 0x00,0x00,0x00,0x00,
                                 0x00,0x00,0x00,0x00,
                                 0x00,0x00,0x00,0x00,
                                 0x00,0x00,0x00,0x00,
                                 0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x05};
        ret = usb_bulk_write(udev, 1, ctl, 64, 5000);
    if( ret < 0 ){
        printf("Read-CmdError\n");
              return(-1);
    }
     ret = usb_bulk_read(udev, 1, uin, 64, 5000);
      if( ret < 0 ){
               printf("Int-Read Error:%d\n", ret);
            return(-2);
        }
printf("Channels:%x(%d)\n",uin[1],uin[1]);
printf("ort 2 Pull Up [0:Able, 1isable]:%x(%d)\n",uin[2],uin[2]);
printf("ort 1 Input Pin:%x\n",uin[5]);
printf("ort 2 Input Pin:%x\n",uin[6]);
printf("ort 3 Input Pin:%x\n",uin[7]);
printf("ort 1 Output:%x\n",uin[9]);
printf("ort 2 Output:%x\n",uin[10]);  
printf("ort 3 Output:%x\n",uin[11]);
printf("ulse Timing:%x(%f) us\n", uin[13], (1158 - (float)uin[13] * 4) * (4/48));
printf("WM [0isable, 1:Able]:%x(%d)\n",uin[14],uin[14]);
return(1);


}
Reply

Use magic Report

Post time 20-12-2010 09:47 PM | Show all posts
Reply 3# botolkicapmanis

sory la.aku x fhm satu apa pun.baek kau tny org kedai tu je
Reply

Use magic Report

Post time 22-12-2010 11:49 PM | Show all posts
Reply 3# botolkicapmanis

ni program ni dah pakai memori computer address...

aku sendiri pun x paham.

tp ms kerja dolu2 mmg ada jumpa la program yg guna nombor2 address ni.

x sempat nak study plk time tu...
Reply

Use magic Report

 Author| Post time 23-12-2010 09:15 PM | Show all posts
Reply 5# otai_g


    ni usb punya program... isk tak reti laaaa camnee niiii???
Reply

Use magic Report

Follow Us
Post time 27-12-2010 06:21 PM | Show all posts
baca la sdk ..
Reply

Use magic Report

Post time 1-1-2011 01:41 PM | Show all posts
aku rasa2 aa.. program tu mcm usb port status info (modules/functions/procedures sahaja ~ bukan main prog)
utk submit signal, kena aa modified.
Reply

Use magic Report


ADVERTISEMENT


Post time 7-1-2011 03:39 PM | Show all posts
aku faham maksud ngko...bypass sensor terus bukak alarm pasang lampu dan send email...nie mcm security purpose laa nih...guna linux supaya boleh hantar email...coz dah ada smtp protokol dlm tuh tak mcm microsoft...
yg ngko paste tuh..dah compile ke blom..apa outputnya kalo dah compile....???
Reply

Use magic Report

Post time 7-1-2011 06:12 PM | Show all posts
aku cuma fhm part die detect usb jerk... kena kaji dulu br bleh... dah lame tggl kerjaya programmer nih...
Reply

Use magic Report

Post time 26-1-2011 08:34 PM | Show all posts
Reply  otai_g


    ni usb punya program... isk tak reti laaaa camnee niiii???
botolkicapmanis Post at 23-12-2010 21:15



    hik3.... .. kena buat juga ke projek nih???
detect movement pakai benda lain xboleh ke???
example : web cam detect movement.. alert and then hantar email..

ckp kt cikgu "xbaik taww bg keje susah2"
Reply

Use magic Report

Post time 1-4-2011 03:16 PM | Show all posts
xde ke SDK ke?..biasanya benda2 mcm ni kita just include library/dll je, pastu kita manipulate I/O...hmmmm...
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

20-5-2024 10:12 AM GMT+8 , Processed in 0.080691 second(s), 38 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list