<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forums.obdev.at/app.php/feed/topic/4674" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2010-08-02T13:49:06+02:00</updated>

	<author><name><![CDATA[Objective Development Forums]]></name></author>
	<id>https://forums.obdev.at/app.php/feed/topic/4674</id>

		<entry>
		<author><name><![CDATA[christian]]></name></author>
		<updated>2010-08-02T13:49:06+02:00</updated>

		<published>2010-08-02T13:49:06+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=4674&amp;p=15412#p15412</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=4674&amp;p=15412#p15412"/>
		<title type="html"><![CDATA[Re: Bug in Wiki (or) in &quot;PowerSwitch&quot; [solved]]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=4674&amp;p=15412#p15412"><![CDATA[
Note that PowerSwitch ships with a really old version of the driver. It has not been updated since the driver comes in a separate package now (see <!-- m --><a class="postlink" href="http://www.obdev.at/products/vusb/download.html">http://www.obdev.at/products/vusb/download.html</a><!-- m -->). The wiki documentation refers to more recent versions.<br /><br />Regarding USB_ENDPOINT_IN vs. USB_ENDPOINT_OUT in the host side software of PowerSwitch: This code was written for the very first version of V-USB (AVR-USB at that time). OUT transfers were not supported by that version and since we only want to transfer data in the setup block, an IN transfer can be used as well.<br /><br />We don't update PowerSwitch for newer versions of V-USB because the driver ships with very simple examples now.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=8">christian</a> — Mon Aug 02, 2010 1:49 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[laurentppol]]></name></author>
		<updated>2010-07-30T22:39:00+02:00</updated>

		<published>2010-07-30T22:39:00+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=4674&amp;p=15394#p15394</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=4674&amp;p=15394#p15394"/>
		<title type="html"><![CDATA[Re: Bug in Wiki (or) in &quot;PowerSwitch&quot; [solved]]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=4674&amp;p=15394#p15394"><![CDATA[
The BUGS (multiple - 4) are on HOST side of example program powerswitch.c:<br /><br /><strong class="text-strong">Original code:</strong><br /><div class="codebox"><p>Code: </p><pre><code>if(strcmp(argv&#91;1&#93;, &quot;on&quot;) == 0){<br />            nBytes = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, PSCMD_ON, duration, port, (char *)buffer, sizeof(buffer), 5000);<br />        }else if(strcmp(argv&#91;1&#93;, &quot;off&quot;) == 0){<br />            nBytes = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, PSCMD_OFF, duration, port, (char *)buffer, sizeof(buffer), 5000);<br /></code></pre></div><br /><br /><strong class="text-strong">Should be:</strong><br /><div class="codebox"><p>Code: </p><pre><code>if(strcmp(argv&#91;1&#93;, &quot;on&quot;) == 0){<br />            nBytes = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, PSCMD_ON, duration, port, (char *)buffer, 0, 5000);<br />        }else if(strcmp(argv&#91;1&#93;, &quot;off&quot;) == 0){<br />            nBytes = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, PSCMD_OFF, duration, port, (char *)buffer, 0, 5000);<br /></code></pre></div><br /><br />Comment:<br />1). we don't really want transfer anything to device in THIS example (apart command, port and duration included in SETUP phase), so put length of data = 0 instead of sizeof(buffer) which will be correct for IN transfer (&quot;status&quot; command)..<br />2). change IN to OUT does NOT affect this project (look point 1) but SHOULD be OUT in case someone want to extend data transfer TO device (using DATA phase, as described in WiKi).<br /><br />That comment (and solution costed me 3 afternoons...), wrrrr.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=4149">laurentppol</a> — Fri Jul 30, 2010 10:39 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[laurentppol]]></name></author>
		<updated>2010-07-27T01:33:54+02:00</updated>

		<published>2010-07-27T01:33:54+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=4674&amp;p=15329#p15329</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=4674&amp;p=15329#p15329"/>
		<title type="html"><![CDATA[Bug in Wiki (or) in &quot;PowerSwitch&quot; [solved]]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=4674&amp;p=15329#p15329"><![CDATA[
Hi, I'am trying to understand V-USB, so I have started with PowerSwitch as it is said to be &quot;pure basics&quot;.<br />On my board I have an LCD, so I included (original) lcd.h/lcd.c (after configuring pins - works OK).<br />(my &quot;target&quot; is something like lcd2usb but this project does NOT work for me... <img class="smilies" src="./../../../images/smilies/icon_sad.gif" alt=":(" title="Sad" /> )<br /><br />Now the PowerSwitch: control transfers work OK (can send wIndex, wValue, even wLength is transferred to device), receive: works (at least default 2 byte return).<br /><br />Now I want to send more data (4-8bytes). According to Wiki changed:<br />USB_CFG_IMPLEMENT_FN_READ to 1, <br /><br />added:<br />usbMsgLen_t usbFunctionSetup(uchar setupData[8])<br />...<br />        currentPosition = 0;                // initialize position index<br />        bytesRemaining = rq-&gt;wLength.word;  // store the amount of data requested<br />        if(bytesRemaining &gt; sizeof(buffer)) // limit to buffer size<br />            bytesRemaining = sizeof(buffer);<br />        return USB_NO_MSG;        // tell driver to use usbFunctionWrite()<br />...<br /><br />added:<br />uchar usbFunctionWrite(uchar *data, uchar len)<br />{<br />    uchar i;<br />    if(len &gt; bytesRemaining)                // if this is the last incomplete chunk<br />        len = bytesRemaining;               // limit to the amount we can store<br />    bytesRemaining -= len;<br />    for(i = 0; i &lt; len; i++)<br />        buffer[currentPosition++] = data[i];<br />...<br />&quot;blinkLED()&quot;<br />...<br />    return bytesRemaining == 0;             // return 1 if we have all data<br />}<br /><br />Problem #1: compiler says: there is NO USB_NO_MSG defined. After a quic search in other downloader project I have found it's declaraction. Copied to usbdrv.h.<br /><br />So bug is in (current?) usbdrv.h or in Wiki?<br /><br />Problem #2:<br />compile OK, but &quot;blinkLED&quot; NEVER get called.<br /><br />I have located, that in this fragment of usbdv.c:<br />&quot;                    /* 1: CLEAR_FEATURE, 3: SET_FEATURE, 7: SET_DESCRIPTOR */<br />                    /* 12: SYNCH_FRAME */<br />                }<br />                #undef SET_REPLY_LEN<br />            }else{  /* not a standard request -- must be vendor or class request */<br />                replyLen = usbFunctionSetup(data);<br />            }<br />#if USB_CFG_IMPLEMENT_FN_READ || USB_CFG_IMPLEMENT_FN_WRITE<br />            if(replyLen == 0xff){   /* use user-supplied read/write function */<br />                if((rq-&gt;bmRequestType &amp; USBRQ_DIR_MASK) == USBRQ_DIR_DEVICE_TO_HOST){<br />                    replyLen = rq-&gt;wLength.bytes[0];    /* IN transfers only */<br />                }<br />                flags &amp;= ~USB_FLG_USE_DEFAULT_RW;  /* we have no valid msg, use user supplied read/write functions */<br />            }else   /* The 'else' prevents that we limit a replyLen of 0xff to the maximum transfer len. */<br />#endif<br />            if(!rq-&gt;wLength.bytes[1] &amp;&amp; replyLen &gt; rq-&gt;wLength.bytes[0])  /* limit length to max */<br />                replyLen = rq-&gt;wLength.bytes[0];<br />        }<br />        /* make sure that data packets which are sent as ACK to an OUT transfer are always zero sized */<br />    }else{  /* DATA packet from out request */<br />blinkLED();<br /><br />#if USB_CFG_IMPLEMENT_FN_WRITE<br />        if(!(usbMsgFlags &amp; USB_FLG_USE_DEFAULT_RW)){<br />            uchar rval = usbFunctionWrite(data, len);<br />            replyLen = 0xff;<br />            if(rval == 0xff){       /* an error occurred */<br />                usbMsgLen = 0xff;   /* cancel potentially pending data packet for ACK */<br />                usbTxLen = USBPID_STALL;<br />            }else if(rval != 0){    /* This was the final package */<br />                replyLen = 0;       /* answer with a zero-sized data packet */<br />            }<br />            flags = 0;    /* start with a DATA1 package, stay with user supplied write() function */<br />        }<br />#endif<br />    }<br />    usbMsgFlags = flags;&quot;<br /><br />control NEVER reaches &quot;    }else{  /* DATA packet from out request */&quot;<br /><br />What is the problem, and what can I do to make it work?<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=4149">laurentppol</a> — Tue Jul 27, 2010 1:33 am</p><hr />
]]></content>
	</entry>
	</feed>
