News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

i want to config camera

Started by ayoub, May 08, 2016, 10:04:28 PM

Previous topic - Next topic

ayoub

hi
i have a web camera for pc and i lost cd configuration so i want to how can i define a cam ?
please
thank

hutch--

Show us the code you have written in assembler and someone may be able to help you. It sounds like you need to track down the company that made the camera and see if you can get a copy of the installation/configuration files that you need.

ayoub

#2
I have a web camera it name ZNITH and i use some to read and write from serial port to read how the array write from camera but it not me it give a some eurror from serial setting "undefined variable"
this is code:
.486
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib

.data
szFrameError db "!"                            ; Display character for errors
displaystring1 db "Monitoring for Data:",0     ; Output display string

.data?
hSerialPort DWORD ?                             ; handle for serial port
SerialSettings DCB {?}                          ; settings for serial port
SerialTimeOuts COMMTIMEOUTS {?}                 ; timeout settings for serial port
NumberOfBytesRead DWORD ?                       ; rcv variable for bytes read from ReadFile
EvtMask DWORD ?                                 ; rcv variable for comm event returned
SerialError DWORD ?                             ; holder for error occured
RcvBuffer DWORD ?                               ; variable for holding input to go to screen

hConsoleOutput DWORD ?                          ; Handle to the display console
ConsoleWriteBytes DWORD ?                       ; rcv variable for bytes written to console

.const
Comm1 db "COM1:", 0                             ; Comm port constants
Comm2 db "COM2:", 0
Comm3 db "COM3:", 0

.code
start:
;-----------------------------
; Allocate a console for displaying output
;-----------------------------
invoke AllocConsole
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov hConsoleOutput, eax
; do not process control codes, display thier hex equivalents
invoke SetConsoleMode, hConsoleOutput, ENABLE_WRAP_AT_EOL_OUTPUT

;-----------------------------
; Serial Port initialization
;-----------------------------
invoke CreateFile, ADDR Comm1, GENERIC_READ OR\         ; Open the Serial Port
    GENERIC_WRITE,0, NULL, OPEN_EXISTING,0,NULL
mov hSerialPort, eax                                    ; save the handle
mov SerialSettings.DCBlength, SIZEOF DCB                ; configure the Settings variable
invoke GetCommState, hSerialPort, ADDR SerialSettings   ; fill it with the current settings
mov SerialSettings.BaudRate, CBR_19200                  ; Baud Rate
mov SerialSettings.ByteSize, 8                          ; Data Bits: 8
mov SerialSettings.Parity, NOPARITY                     ; Parity: None
mov SerialSettings.StopBits, ONESTOPBIT                 ; Stop Bits: 1
mov SerialSettings.fOutxCtsFlow, FALSE                  ; No RTS
mov SerialSettings.fRtsControl, RTS_CONTROL_DISABLE     ; No CTS
mov SerialSettings.fOutxDsrFlow, FALSE                  ; No DSR TX inhibiting
mov SerialSettings.fDsrSensitivity, FALSE               ; No DSR RX inhibiting
mov SerialSettings.fDtrControl, DTR_CONTROL_ENABLE      ; Enable DTR Signal
mov SerialSettings.fOutX, TRUE                          ; xOn/xOff enabled for TX
mov SerialSettings.fInX, FALSE                          ; Suspend Xon/Xoff for RCV
mov SerialSettings.fNull, TRUE                          ; Discard NULL bytes
mov SerialSettings.fAbortOnError, FALSE                 ; Do not Abort on Error
mov SerialSettings.fBinary, TRUE                        ; Binary Transfer
mov SerialSettings.fParity, TRUE                        ; Parity Enabled
invoke SetCommState, hSerialPort, ADDR SerialSettings   ; Apply the new settinsg

; Set the Time-outs to occur immedietly with everything in the buffer
invoke GetCommTimeouts, hSerialPort, ADDR SerialTimeOuts
mov SerialTimeOuts.ReadIntervalTimeout, MAXDWORD
mov SerialTimeOuts.ReadTotalTimeoutMultiplier, 0
mov SerialTimeOuts.ReadTotalTimeoutConstant, 0
mov SerialTimeOuts.WriteTotalTimeoutMultiplier, 0
mov SerialTimeOuts.WriteTotalTimeoutConstant, 0
invoke SetCommTimeouts, hSerialPort, ADDR SerialTimeOuts

;Generate events for received bytes and errors
invoke SetCommMask, hSerialPort, (EV_RXCHAR OR EV_ERR)
;------------------------------------------------------

invoke WriteConsole, hConsoleOutput, ADDR displaystring1, \  ; display a prompt
    SIZEOF displaystring1, ADDR NumberOfBytesRead, NULL
   
;-----------------------------
; Poll the serial port for RCV data
;-----------------------------

.WHILE TRUE                                                 ; Enter an endless loop
invoke WaitCommEvent, hSerialPort, ADDR EvtMask, NULL      ; Hold up for either a character or an error

.IF EvtMask == EV_ERR                                      ; If an error came in...
  invoke SetConsoleTextAttribute, hConsoleOutput,\          ; change to a red font
   FOREGROUND_RED
  invoke WriteConsole, hConsoleOutput, ADDR szFrameError,\  ; print an exclamation point
   SIZEOF szFrameError, ADDR ConsoleWriteBytes, NULL
  invoke SetConsoleTextAttribute, hConsoleOutput,\          ; change back to white font
   FOREGROUND_BLUE OR FOREGROUND_GREEN OR FOREGROUND_RED
  invoke ClearCommError, hSerialPort, ADDR SerialError, NULL; clear the error
.ENDIF

.IF EvtMask == EV_RXCHAR                                   ; if a chracter was recieved...
  .WHILE TRUE                                               ; start a loop to empty out the serial port
   invoke ReadFile, hSerialPort, RcvBuffer, SIZEOF\         ; Read in one DWORD from the serial port
    RcvBuffer, ADDR NumberOfBytesRead, NULL
   .BREAK .IF NumberOfBytesRead == 0                        ; exit if the buffer is empty
   invoke WriteConsole, hConsoleOutput, RcvBuffer,\         ; print out any characters recieved
    NumberOfBytesRead, ADDR ConsoleWriteBytes, NULL
  .ENDW
.ENDIF
.ENDW

invoke CloseHandle, hSerialPort                             ; close the serial port
invoke ExitProcess, NULL                                     ; End the Program

END start

Thank

jj2007

Windows.inc, line 12205:

DCB STRUCT
  DCBlength     DWORD      ?
  BaudRate      DWORD       ?
  fbits         BITRECORD      <>
  wReserved     WORD       ?
  XonLim        WORD          ?
  XoffLim       WORD         ?
  ByteSize      BYTE        ?
  Parity        BYTE          ?
  StopBits      BYTE        ?
  XonChar       BYTE         ?
  XoffChar      BYTE        ?
  ErrorChar     BYTE       ?
  EofChar       BYTE         ?
  EvtChar       BYTE         ?
  wReserved1    WORD       ?
DCB ENDS


Use this version:
DCBJJ STRUCT
DCBlength DWORD ?
BaudRate  DWORD ?
fBinary    DWORD ?
fParity    DWORD ?
fOutxCtsFlow DWORD ?
fOutxDsrFlow DWORD ?
fDtrControl DWORD ?
fDsrSensitivity DWORD ?
fTXContinueOnXoff DWORD ?
fOutX      DWORD ?
fInX      DWORD ?
fErrorChar DWORD ?
fNull      DWORD ?
fRtsControl DWORD ?
fAbortOnError DWORD ?
fDummy2    DWORD ?
wReserved WORD ?
XonLim    WORD ?
XoffLim    WORD ?
ByteSize  BYTE ?
Parity    BYTE ?
StopBits  BYTE ?
XonChar    CHAR ?
XoffChar  CHAR ?
ErrorChar CHAR ?
EofChar    CHAR ?
EvtChar    CHAR ?
wReserved1 WORD ?
DCBJJ ENDS

.data?
hSerialPort DWORD ?                             ; handle for serial port
SerialSettings DCBJJ {?}                          ; settings for serial port


ayoub

thank for help
but were is code to write the first or second to difine variable , i have a windows 95

jj2007

Quote from: ayoub on May 12, 2016, 07:07:53 PMbut were is code to write the first or second to difine variable , i have a windows 95

You won't get help if your requests are so vague.

ayoub

so
me idea i want to read the array from camera and put this array in opengl to play the camera

jj2007

Where is your "code to write the first or second to difine variable"? And what does that sentence mean?

ayoub

Did you add the first "Windows.inc, line 12205" or "the second Use this version" or both code to run in win 95
thank

jj2007

Only the second version works. I don't have Windows 95 to test it.

ayoub

thank you for help
:greenclp:
i have a question i want to build a hex file , can i do that by masm

jj2007


ayoub

how can i do a hex file or other file like binaire

jj2007

1. define your task
2. read the manuals (\masm32\help)
3. start coding
4. in case you have problems, post your code here and ask intelligent questions

ayoub


I want a method of producing hex file like a namefile.hex
i want the code or way to build hex file