[Gambas-user] Parallel Port - Illegal Seek -
mike
euph1 at ...734...
Wed Apr 7 22:05:08 CEST 2010
On 04/07/2010 02:47 PM, nando wrote:
> Seek will not change the address.
>
>
> ---------- Original Message -----------
> From: Doriano Blengino<doriano.blengino at ...1909...>
> To: nando_f at ...951..., mailing list for gambas users
> <gambas-user at lists.sourceforge.net>
> Sent: Wed, 07 Apr 2010 11:06:42 +0200
> Subject: Re: [Gambas-user] Parallel Port - Illegal Seek -
>
>
>> nando ha scritto:
>>
>>> Using SEEK is not correct.
>>> If you think of the parallel port as a file, you cannot seek.
>>> It doesn't make sense.
>>> You can only read and write.
>>> What are you trying to accomplish ?
>>> -Fernando
>>>
>>>
>> He is trying to do low level access to the parallel port, which has 3
>> hardware addresses.
>> In that respect, seek() would make sense to select which IO address to
>> read from/write to.
>> Whether this works or not, depends on how the kernel driver interprets
>> the seeks, but the following listing makes it clear that somewhere
>> (other OSes?) this behavior works.
>> The error could also arise from other problems: permissions, missing
>> modules, wrong major/minor numbers and so on...
>>
>> Regards,
>> Doriano
>>
>>
>>>
>>> ---------- Original Message -----------
>>> From: Bjorn Macintosh<bjorn.macintosh at ...626...>
>>> To: gambas-user at lists.sourceforge.net
>>> Sent: Fri, 2 Apr 2010 21:09:58 +1300
>>> Subject: [Gambas-user] Parallel Port - Illegal Seek -
>>>
>>>
>>>
>>>> Hi All,
>>>>
>>>> I am writing a parallel port interface, however I am struggling with how to
>>>> write to the parallel port. Below I have included the code that I have
>>>> used. Following that I have included the BASIC code that I am bastardizing.
>>>>
>>>> My Gambas version is Gambas2.13
>>>> I am running Linux Mint 8
>>>> I do have a parallel port on my PC. It is '0378' - '037a' and '0778' -
>>>> '077a'
>>>> The error code I am getting is "System error. illegal seek"
>>>>
>>>> Thanks in advance for any help anyone can give.
>>>> ---------------------------------------------------------------------GAMBAS2
>>>> CODE FOLLOWS------------------------------------------------------
>>>> ' Gambas module file
>>>> PUBLIC SUB Main()
>>>>
>>>> DIM N AS Integer
>>>> DIM pin AS Integer
>>>> DIM pinout AS Integer[] = [0, 0, 0, 0, 0, 0, 0, 0]
>>>> DIM pump AS Integer
>>>> DIM Ptime AS Integer
>>>> DIM Clock AS Integer
>>>> DIM UClock AS Integer
>>>> DIM DClock AS Integer
>>>> DIM commit AS Integer
>>>> DIM poweron AS Integer
>>>> DIM switch AS Integer
>>>> DIM gate AS File
>>>> DIM base0, base1, base2 AS Integer
>>>>
>>>> base0 = 0
>>>> base1 = 1
>>>> base2 = 2
>>>> poweron = 64
>>>> commit = 144
>>>> switch = 17
>>>> UClock = 130
>>>> DClock = 128
>>>> gate = OPEN "/dev/parport0" FOR READ WRITE
>>>> SEEK #gate, base0
>>>> WRITE #gate, poweron
>>>> FOR Ptime = 1 TO 2000 STEP 1
>>>> NEXT
>>>>
>>>> SEEK #gate, base2
>>>> WRITE #gate, switch
>>>>
>>>> GOTO START
>>>> CommitChanges:
>>>> FOR N = 0 TO 7 STEP 1
>>>> pump = CInt(1000000& pinout[Fix(N)])
>>>> Clock = CInt(1000001& pinout[Fix(N)])
>>>> SEEK #gate, base0
>>>> WRITE #gate, pump
>>>> FOR Ptime = 1 TO 2000 STEP 1
>>>> NEXT
>>>> SEEK #gate, base0
>>>> WRITE #gate, Clock
>>>> FOR Ptime = 1 TO 2000 STEP 1
>>>> NEXT
>>>> SEEK #gate, base0
>>>> WRITE #gate, pump
>>>> NEXT
>>>> FOR Ptime = 1 TO 2000 STEP 1
>>>> NEXT
>>>>
>>>> FOR N = 1 TO 16 STEP 1
>>>> SEEK #gate, base0
>>>> WRITE #gate, UClock
>>>> FOR Ptime = 1 TO 2000 STEP 1
>>>> NEXT
>>>> SEEK #gate, base0
>>>> WRITE #gate, DClock
>>>> NEXT
>>>> FOR Ptime = 1 TO 2000 STEP 1
>>>> NEXT
>>>> SEEK #gate, base0
>>>> WRITE #gate, commit
>>>> FOR Ptime = 1 TO 2000 STEP 1
>>>> NEXT
>>>> SEEK #gate, base0
>>>> WRITE #gate, poweron
>>>> GOTO PrintPinout
>>>>
>>>> PrintPinout:
>>>> FOR N = 0 TO 7 STEP 1
>>>> PRINT pinout[Fix(N)]
>>>> NEXT
>>>> GOTO START
>>>>
>>>> PinSelectFail:
>>>> PRINT "You have selected a pin that does not exist, careful as this may
>>>> cause a divide by 0 and end the universe, Select between pin 0 and pin 7"
>>>> GOTO START
>>>>
>>>> START:
>>>> PRINT "What input do you want to toggle? (pins 0 -> 7 are outputs, Pin 8
>>>> is the activation sequence)"
>>>> INPUT pin
>>>> IF pin< 0 OR pin> 8 THEN
>>>> GOTO PinSelectFail
>>>> ELSE IF pin = 8 THEN
>>>> GOTO CommitChanges
>>>> ELSE IF pinout[Fix(pin)] = 0 THEN
>>>> pinout[Fix(pin)] = 1
>>>> ELSE IF pinout[Fix(pin)] = 1 THEN
>>>> pinout[Fix(pin)] = 0
>>>> ENDIF
>>>> GOTO PrintPinout
>>>> END
>>>> ---------------------------------------------------------------------Gambas2
>>>> END------------------------------------------------------------------------
>>>>
>>>> ---------------------------------------------------------------------BASIC
>>>> CODE FOLLOWS------------------------------------------------------
>>>>
>>>> BASE0=&H378
>>>>
>>>> 'SWITCH POWER AND OUTPUTS ON
>>>> OUT BASE0,&H80
>>>> OUT BASE0 + 2, 11
>>>>
>>>> 'DEFINE ALL DIGITAL OUTPUTS [OUT(N)] AS BEING OFF (0)
>>>> FOR N = 0 TO 7
>>>> DOUT(N) = 0
>>>> NEXT N
>>>> DOUT=0
>>>>
>>>> START:
>>>> INPUT "WHICH DIGITAL OUTPUT DO YOU WANT TO TOGGLE (0 TO 7)...."; N
>>>> IF N< 0 OR N> 7 THEN GOTO START
>>>> N = FIX(N)
>>>> DOUT9N0=ABS(NOT (-DOUT(N))) ' THIS LINE TOGGLES THE OUTPUT
>>>>
>>>> 'CREATE COMPLETE BYTE FOR IC3 CALLED DOUT
>>>> FOR N = 0 TO 7
>>>> IF DOUT(N) = 0 THEN
>>>> DOUT = DOUT AND NOT (2^N)
>>>> ELSE
>>>> DOUT = DOUT OR 2^N
>>>> ENDIF
>>>> NEXT N
>>>>
>>>> 'SEND 8 CLOCK PULSES AND DIGITAL OUT DATA (ALL ZERO'S)
>>>> FOR BIT = 1 TO 8
>>>> B = 8 - BIT
>>>> BYTE = ((DOUT AND 2^B) / 2^B) OR&H80
>>>> OUT BASE0, BYTE
>>>> OUT BASE0, BYTE OR 2
>>>> OUT BASE0 BYTE
>>>> NEXT BIT
>>>>
>>>> 'SEND ANOTHER 16 CLOCK PULSES TO SHIFT THE DATA INTO IC3
>>>> FOR BIT = 9 TO 24
>>>> OUT BASE0,&H82
>>>> OUT BASE0,&H80
>>>> NEXT BIT
>>>>
>>>> 'LOAD IC3
>>>> OUT BASE0,&H90
>>>> OUT BASE0,&h80]
>>>>
>>>> ---------------------------------------------------------------------BASIC
>>>> END------------------------------------------------------------------------
>>>>
>>>> Bjorn Macintosh
>>>> ------------------------------------------------------------------------------
>>>>
>>>>
>> ------------------------------------------------------------------------------
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
> ------- End of Original Message -------
>
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
What will change the address?
More information about the User
mailing list