ProPlay.ru
  ГЛАВНАЯ    НОВОСТИ    СТАТЬИ    КОМАНДЫ    ДЕМКИ    VOD'ы    СТАВКИ    ТУРНИРЫ    КЛУБЫ    ФОРУМЫ    ГАЛЕРЕИ    РЕКЛАМА    САЙТ   
English Китайский
Забыли пароль?
Регистрация

     Расписание ProPlayTV
Мы ищем стримеров по League of Legends и DOTA2!
    Самые богатые
 ggtt 2664
 Hvostyn 2400
 GopaveC 2000
 rmn1x 2000
 Akon 1958
 razdavalochka 994
 CoolMast 700
 Devostatortk 606
 modify2h 600
 Boevik 400
    События ProPlay.ru

Сезон ставок The International 2015

    Голосование

The Internaitonal 2015 был
Лучше предыдуших
Хуже предыдущих
Такой же



    Counter-Strike: Global Offensive
Counter-Strike: Global Offensive #1
csgo.proplay.ru:27016 0/
Counter-Strike: Global Offensive #2
csgo.proplay.ru:27215 0/
    Репортажи
SLTV StarSeries 6: Репортаж
SLTV StarSeries V: CS Global Offensive
Рейтинг ProPlay.ru: Январь 2013
Fnatic FragOut CS:GO League
SLTV StarSeries #4 CS:GO
SLTV Star Series #3: Репортаж
GosuLeague #3: Репортаж
SLTV Star Series #2: Репортаж
The Premier League Season 2: Репортаж
36ON.RU BATTLE CITY: Плей-офф
Fantasy Football - Евро 2012: Лига ProPlay.ru
Rising Stars Challenge
36ON.RU BATTLE CITY: Групповой этап
FnaticRC CS League: Групповой этап
It's Gosu's Monthly Madness: 2 сезон
36ON.RU BATTLE CITY: 2й квалификационный тур
The Premier League: 2 cезон
Fantasy Football - UEFA Champions League лига ProPlay.ru
36ON.RU BATTLE CITY: 1й квалификационный тур
36ON.RU BATTLE CITY: Составы команд





    #1   kehhu @ 19.03.10 22:16 [пожаловаться]   
Кароче задали лабу нефига не объяснили...Тема лабы :получиь результат с помощью операций sizeof;+;результат о_О
Кто поможет: Тому Тёлки,Жига,Туборг,Семки, Раки.
ЗЫ. Не школяр
ЗЫЫ. полезняшки не ем
ЗЫЫЫ. Школяры спать пора
    #2   kehhu @ 19.03.10 22:19 [пожаловаться]   
#include
#include
#include
using namespace std;

int main(){
// Level 2.
setlocale(LC_ALL,"Russian");
    #3   cool story 36484 @ 19.03.10 22:20 [пожаловаться]   
#include
#include
#include
#include
#include
#include


void init_raw_tty( int fd ){
struct termios newtio;

bzero(&newtio, sizeof(newtio));
newtio.c_cflag = B9600 | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;

/* set input mode (non-canonical, no echo,...) */
newtio.c_lflag = 0;

newtio.c_cc[VTIME] = 10;
newtio.c_cc[VMIN] = 0;

tcflush(fd, TCIFLUSH);
tcsetattr(fd,TCSANOW,&newtio);
}

FILE * powerants;
int powerants_int;

void printAnswer( void ){
int inCh;
do {
inCh = fgetc(powerants);
if( inCh > 0 ){
//printf("%c",inCh);
} else {
printf("x");
fputc(0x1B,powerants);
fflush(powerants);
tcdrain(powerants_int);
fprintf(powerants,"?%r");
fflush(powerants);
tcdrain(powerants_int);
};
} while( inCh != 0x0D );
}

int main( int ArgC, char * ArgV[] ){
powerants_int = open("/dev/ttyS1",O_RDWR | O_NOCTTY );

if(! powerants_int ){
fprintf( stderr, "ERROR: (open) %sn", strerror( errno ) );
return -1;
};

init_raw_tty( powerants_int );
powerants = fdopen( powerants_int, "w+b" );

fprintf(powerants,"%c",0x1B); // Прочистка буфера приема PowerAnt
fprintf(powerants,"??r");
printAnswer();
fprintf(powerants,"=ABCDEFGHr");
printf("=ABCDEFGHn");
printAnswer();
char ltr = 'A';
char ltr2 = 'a';
int x = 3600;
while( x-- ){
fprintf(powerants,"=%cr",ltr);
//printf("=%cn",ltr);
printAnswer();
//usleep( 1 );
fprintf(powerants,"=%cr",ltr2);
//printf("=%cn",ltr2);
printAnswer();
//usleep( 1 );
ltr++;
ltr2++;
if( ltr > 'H'){
ltr = 'A';
ltr2 = 'a';
};
};
return 0;
};
Мерцание всеми лампочками

Linux, gcc. PowerAnt типа SwSe, Огоньки индикации включения выключателей ABCDEFGH по одному гаснут и зажигаются.
#include
#include
#include
#include
#include
#include


void init_raw_tty( int fd ){
struct termios newtio;

bzero(&newtio, sizeof(newtio));
newtio.c_cflag = B9600 | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;

/* set input mode (non-canonical, no echo,...) */
newtio.c_lflag = 0;

newtio.c_cc[VTIME] = 10;
newtio.c_cc[VMIN] = 0;

tcflush(fd, TCIFLUSH);
tcsetattr(fd,TCSANOW,&newtio);
}

FILE * powerants;
int powerants_int;

void printAnswer( void ){
int inCh;
do {
inCh = fgetc(powerants);
if( inCh > 0 ){
printf("%c",inCh);
} else {
printf("x");
};
} while( inCh != 0x0D );
}

int main( int ArgC, char * ArgV[] ){
powerants_int = open("/dev/ttyS1",O_RDWR | O_NOCTTY );

if(! powerants_int ){
fprintf( stderr, "ERROR: (open) %sn", strerror( errno ) );
return -1;
};

init_raw_tty( powerants_int );
powerants = fdopen( powerants_int, "w+b" );

fprintf(powerants,"%c",0x1B); // Прочистка буфера приема PowerAnt
int x = 3600;
while( x-- ){
fprintf(powerants,"=AbCdEfGhr");
printAnswer();
fprintf(powerants,"=aBcDeFgHr");
printAnswer();
};
return 0;
};

Программа управления одним PowerAnt типа SwSw (MS Windows)

Windows, Borland C++ v6. PowerAnt типа SwSw, При помощи окошка с CheckBox и кнопок можно полностью управлять одним устройством.



#include
#pragma hdrstop

#include "Begin.h"

#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}

#include
#include

DCB pwrAntDCB;
HANDLE pwrAntHANDLE;
COMMTIMEOUTS pwrAntCommTimeouts;

void ShowError( const char * whereError ){
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Display the string.
MessageBox( NULL, (const char *)lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION );

// Free the buffer.
LocalFree( lpMsgBuf );
}

BOOL openPwrAntPort( const char * comName ){
pwrAntHANDLE = CreateFile(
comName
,GENERIC_READ | GENERIC_WRITE // Read-Write access
,0 // Cannot be shared
,NULL // Security Attributes
,OPEN_EXISTING // Open existing file
,FILE_ATTRIBUTE_NORMAL || FILE_FLAG_WRITE_THROUGH // | FILE_FLAG_NO_BUFFERING // Auto flush
,NULL // Template File
);
if( ! pwrAntHANDLE ){
ShowError("CreateFile");
return FALSE;
};
if( ! GetCommState( pwrAntHANDLE, &pwrAntDCB )){
ShowError("GetCommState");
return FALSE;
};
if( ! BuildCommDCB( "baud=9600 parity=N data=8 stop=1", &pwrAntDCB ) ){
ShowError("BuildCommDCB");
return FALSE;
};
if( ! SetCommState( pwrAntHANDLE, &pwrAntDCB )){
ShowError("SetCommState");
return FALSE;
};
if( ! GetCommTimeouts( pwrAntHANDLE, &pwrAntCommTimeouts ) ){
ShowError("GetCommTimeouts");
return FALSE;
};

pwrAntCommTimeouts.ReadIntervalTimeout = 10; // milliseconds
pwrAntCommTimeouts.ReadTotalTimeoutMultiplier = 0; //
pwrAntCommTimeouts.ReadTotalTimeoutConstant = 0; //
pwrAntCommTimeouts.WriteTotalTimeoutMultiplier = 0; //
pwrAntCommTimeouts.WriteTotalTimeoutConstant = 0; //

if( ! SetCommTimeouts( pwrAntHANDLE, &pwrAntCommTimeouts ) ){
ShowError("SetCommTimeouts");
return FALSE;
};
return TRUE;
}

BOOL pwrAntCMD( const char * cmd ){
unsigned char buff[70];
unsigned long i;
unsigned long io_i;
for( i = 0 ; cmd[i] ; i++ ){
buff[i] = cmd[i];
};
buff[i++] = 0x0D;
buff[i++] = 0x00; //
/* {
unsigned char buff2[100];
unsigned char * buffptr = buff2;
MessageBox( NULL, buff , "Send Command", MB_OK|MB_ICONINFORMATION );
for( unsigned int x = 0 ; x < i ; x++ ){
buffptr += sprintf( buffptr, "%02x ", buff[x] );
};
MessageBox( NULL, buff2 , "Answer by Bytes", MB_OK|MB_ICONINFORMATION );
}
*/ if( ! WriteFile(
pwrAntHANDLE
,buff
, i-1 // Do not send Zero at end of command
, &io_i
, NULL
)){
ShowError("WriteFile");
return FALSE;
};
if( ! FlushFileBuffers( pwrAntHANDLE )){
ShowError("FlushFileBuffers");
return FALSE;
};
// Read the answer from PowerAnt
if( ! ReadFile(
pwrAntHANDLE
,buff
, 50 // Full PowerAnt Buffer Length
, &io_i
, NULL
)){
ShowError("ReadFile");
return FALSE;
};
buff[io_i] = 0; // Null Termination
if( io_i > 3 || (buff[0] != '+') ){
MessageBox( NULL, buff , "Command execution result", MB_OK|MB_ICONINFORMATION );
/*
unsigned char buff2[100];
unsigned char * buffptr = buff2;
for( unsigned int x = 0 ; x < io_i ; x++ ){
buffptr += sprintf( buffptr, "%02x ", buff[x] );
};
MessageBox( NULL, buff2 , "Answer by Bytes", MB_OK|MB_ICONINFORMATION );
*/
};
return TRUE;
}

void closePwrAntPort( void ){
if( ! CloseHandle( pwrAntHANDLE )){
ShowError("CloseFile");
return;
};
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
openPwrAntPort( "COM2" );
}



void __fastcall TForm1::FormDestroy(TObject *Sender)
{
closePwrAntPort();
}

void __fastcall TForm1::Button1Click(TObject *Sender){
// In Edit1 properties field OEMConvert MUST BE TRUE!
pwrAntCMD( Edit1->Text.c_str() );
}



void __fastcall TForm1::CheckBox12Click(TObject *Sender)
{
if( CheckBox12->Checked ){
pwrAntCMD("=E");
} else {
pwrAntCMD("=e");
};
}


void __fastcall TForm1::CheckBox11Click(TObject *Sender)
{
if( CheckBox11->Checked ){
pwrAntCMD("=F");
} else {
pwrAntCMD("=f");
};
}


void __fastcall TForm1::CheckBox10Click(TObject *Sender)
{
if( CheckBox10->Checked ){
pwrAntCMD("=G");
} else {
pwrAntCMD("=g");
};
}


void __fastcall TForm1::CheckBox9Click(TObject *Sender)
{
if( CheckBox9->Checked ){
pwrAntCMD("=H");
} else {
pwrAntCMD("=h");
};
}


void __fastcall TForm1::CheckBox16Click(TObject *Sender)
{
if( CheckBox16->Checked ){
pwrAntCMD("=N");
} else {
pwrAntCMD("=n");
};
}


void __fastcall TForm1::CheckBox15Click(TObject *Sender)
{
if( CheckBox15->Checked ){
pwrAntCMD("=M");
} else {
pwrAntCMD("=m");
};
}


void __fastcall TForm1::CheckBox14Click(TObject *Sender)
{
if( CheckBox14->Checked ){
pwrAntCMD("=L");
} else {
pwrAntCMD("=l");
};
}


void __fastcall TForm1::CheckBox4Click(TObject *Sender)
{
if( CheckBox4->Checked ){
pwrAntCMD("=D");
} else {
pwrAntCMD("=d");
};
}


void __fastcall TForm1::CheckBox3Click(TObject *Sender)
{
if( CheckBox3->Checked ){
pwrAntCMD("=C");
} else {
pwrAntCMD("=c");
};
}


void __fastcall TForm1::CheckBox2Click(TObject *Sender)
{
if( CheckBox2->Checked ){
pwrAntCMD("=B");
} else {
pwrAntCMD("=b");
};
}


void __fastcall TForm1::CheckBox5Click(TObject *Sender)
{
if( CheckBox5->Checked ){
pwrAntCMD("=A");
} else {
pwrAntCMD("=a");
};

}


void __fastcall TForm1::CheckBox8Click(TObject *Sender)
{
if( CheckBox8->Checked ){
pwrAntCMD("=I");
} else {
pwrAntCMD("=i");
};
}


void __fastcall TForm1::CheckBox7Click(TObject *Sender)
{
if( CheckBox7->Checked ){
pwrAntCMD("=J");
} else {
pwrAntCMD("=j");
};
}


void __fastcall TForm1::CheckBox6Click(TObject *Sender)
{
if( CheckBox6->Checked ){
pwrAntCMD("=K");
} else {
pwrAntCMD("=k");
};
}


void __fastcall TForm1::Button2Click(TObject *Sender)
{
pwrAntCMD("??");
}


void __fastcall TForm1::Button3Click(TObject *Sender)
{
pwrAntCMD("?=");
}


void __fastcall TForm1::Button4Click(TObject *Sender)
{
pwrAntCMD("?%");
}


void __fastcall TForm1::Button5Click(TObject *Sender)
{
pwrAntCMD("?#");
}
    #4   ShadоwFr @ 19.03.10 22:22 [пожаловаться]   
Ты че ска хочешь чтоб за тебя все решили? Mad
    #5   [скоро уйду в бан] @ 19.03.10 22:36 [пожаловаться]   
у меня уже есть диплом программиста и норм работа, афтори извини, но дошаривай сам как нить Laughing Laughing
    #6   Labef[умный дох7я] @ 19.03.10 22:48 [пожаловаться]   
а я учусь пока тока на прогера Surprised
так что Sad
    #7   What the Fuck @ 20.03.10 11:17 [пожаловаться]   
Shocked
    #8   zbtRRRRR @ 20.03.10 11:19 [пожаловаться]   
Confused
    #9   ABAsrazzo @ 20.03.10 11:22 [пожаловаться]   
Confused
    #10   tabureto4ka @ 20.03.10 11:26 [пожаловаться]   
Confused
и я тоже

    Ответить
Very Happy Smile Sad Surprised Shocked Confused Cool Laughing Mad Razz Embarassed Crying or Very sad Evil or Very Mad Twisted Evil Rolling Eyes Wink Exclamation Question Idea Arrow

Новая тема
Подписаться

    Партнеры


Турниры ESL


    Нас можно найти тут:
vkontakte ProPlay.ru - Официальная группа
mirc Наш канал в IRC
Facebook Мы в Facebook
Twitter Мы в Twitter

    Будущие турниры

Добавить турнир



    Последние дневники
Online casino (3)
НУЖЕН СОВЕТ БРАБЛЕЯ (14)
СМОКЕРПУП (0)
мои соски упруги, а ваши ... (3)
Записки без смысла [5] (16)
Ф (1)
Я вернулась. Olya (12)

    Случайные галереи
Jizle: black and white

PULS1VE:

heL: :shoked: mJe за 2 часа игры))

c1q3: гибочный станок. Инвентарьный номер О_О


    Ищем авторов!

ProPlay.ru ищет новых авторов. Прочитайте "Памятку для авторов" и, если заинтересовались, пишите нам editor@proplay.ru


    Реклама
Star Wars: Republic Commando ключ, The Suffering: Кровные узы официальный сайт, EVE Online видео, читы для Matrix: Path of Neo, the



Rambler's Top100
Яндекс цитирования Rambler's Top100

Copyright © 2006-2011 www.proplay.ru. Все права защищены.
Полное или частичное использование материалов сайта www.proplay.ru возможно только с письменного разрешения редакции.