Error “TypeError: Serial() takes no arguments” en Python (pySerial, Raspbian)

estoy intentando leer los bytes que entran mediante un usb (el cable que está enchufado en el usb es un conversor usb-serial232).

Yo no se mucho de python,y he estado buscando ayuda por internet hasta que me he encontrado con el siguiente código:

import serial ser = serial.Serial('/dev/ttyUSB0', 9600)  while True:     data = ser.readline()     if data:         print(data) 

Cuando ví esto me dio buenas vibraciones, ya que la forma que tengo de leer el mbus es con una librería de Linux que utiliza el ttyISB0.

La 1era vez que lo ejecuté me pedía que instalase la librería ‘serial’. Como estoy trabajando con PyCharm, con hacer Ctrl-Mayus-Intro se me instalaba sola.

Una vez instalé serial, me dio el error de ‘Serial’ (S mayúscula). Total, que lo instalé también.

Pero me sigue dando el siguiente error:

/root/PycharmProjects/prueba1/venv/bin/python /root/PycharmProjects/prueba1/ Traceback (most recent call last):   File "/root/PycharmProjects/prueba1/", line 2, in <module>     ser = serial.Serial('/dev/ttyUSB0', 9600) TypeError: Serial() takes no arguments  Process finished with exit code 1 

Y ya no se que hacer, he estado mirando en internet, pero no hay nada sobre ese error.

Toda ayuda será bien recibida. Un Saludo

WordPress Codex has different number of arguments for get_previous_post and get_next_post functions. Why?

Compare the following two links:

The get_previous_post function doesn’t have the last $ taxonomy parameter, while get_next_post has it listed. I followed those instruction literally, which caused my get_previous_post to break. When I noticed the difference between the two functions, I tried specifying the taxonomy in my get_previous_post function, which fixed the problem. Is this a mistake in the Codex for get_previous_post?

Exception calling “ExecuteQuery” with “0” argument(s): “The operation has timed out.”

I am trying to delete list items, about 130K, from a large list on SharePoint Online using powershell CSOM, i am getting this error

“Exception calling “ExecuteQuery” with “0” argument(s): “The operation has timed out.””

this is my code

    for ($  i=$  allItems.Count-1; $  i-ge0; $  i--)       {           $  allItems[$  i].DeleteObject()         #$  clientContext.ExecuteQuery()        }        $  clientContext.ExecuteQuery()  

When i use the ExecuteQuery() outside the loop, i am getting this error. but it still deletes around 1K items each time i run the script.

But When i use the ExecuteQuery() inside the loop, it doesn’t throw the error and the script completes execution, BUT it takes about 20 times the time taken to delete items when ExecuteQuery() used outside the loop

i also used RequestTimeout property

$ clientContext.RequestTimeout = [System.Threading.Timeout]::Infinite ( or any value)

it doesn’t seem to honor this property.

Could anyone please help me suggest a better way to delete such a large list ( the list is still being used, i can’t delete the list)?

Thanks so much Maria Francis

Turning arguments into exponents

I’d like to replace every instance of L[stuff], e.g.,


in an expression with x^(-FromDigits[{stuff}]), e.g.


. But I’m running into an issue– I’d like to do this with the code

L[-1, -2, -2] /. L[a___] -> x^(FromDigits[-{a}]) 

but this produces

2/x^6 + x^4 + x^5. 

In trouble-shooting, I noticed that while

L[-1, -2, -2] /. L[a___] -> {a} 

produces the output I expected, namely {-1,-2,-2}, I found that

L[-1, -2, -2] /. L[a___] -> -{a} 

just produces {4} rather than {1,2,2}. I must be misunderstanding how Sequence behaves when it shows up in the right side of a Rule since when I try just inputting -{Sequence[-1,-2,-2]} I get the expected result {1,2,2}. Does anyone see where I’m going wrong? Thanks!

how to create conditional arguments in a function?

I have the following function that hides a password middle chars and leaves 1st and last char visible

function Hide-ConnectionStringPassword {     param(        [parameter(Mandatory,ValueFromPipeline)]        [System.Data.SqlClient.SqlConnectionStringBuilder]$  ConnectionString     )     [string]$  FistChar = $  ConnectionString.Password[0]     [string]$  LastChar = $  ConnectionString.Password[($  ConnectionString.Password.Length - 1)]     [string]$  Stars = '*' * ($  ConnectionString.Password.Length - 2)     $  ConnectionString.Password = $  FistChar + $  Stars + $  LastChar      return $  ConnectionString.ConnectionString } 


Hide-ConnectionStringPassword 'Connection Timeout=120;User Id=UID1;Data;Password=password12!553;' 


Data;User ID=UID1;Password=p************3;Connect Timeout=120

I have other connection strings that are JSON formatted, so the casting to sqlbuilder will not work on this type of input

{“Authentication Kind”:”UsernamePassword”,”Username”:”someID1″,”Password”:”Yu#gh456!ts”,”EncryptConnection”:true}

One thing i could do is something like this:

$  Json = '{"Authentication Kind":"UsernamePassword","Username":"someID1","Password":"Yu#gh456!ts","EncryptConnection":true}' $  Sql = $  Json | ConvertFrom-Json $  Sql.Password 


$  Sql.gettype().name  

i get


i would like to apply that in the function such that it checks string input is type pscustomobject so that it doesnt cast it as sqlbuilder


function Hide-ConnectionStringPassword {     if ($  input.gettype().name -ne 'PSCustomObject')     {     param(        [parameter(Mandatory,ValueFromPipeline)]        [System.Data.SqlClient.SqlConnectionStringBuilder]$  ConnectionString     )}     else     {     param(        [parameter(Mandatory,ValueFromPipeline)]        $  ConnectionString     )}     [string]$  FistChar = $  ConnectionString.Password[0]     [string]$  LastChar = $  ConnectionString.Password[($  ConnectionString.Password.Length - 1)]     [string]$  Stars = '*' * ($  ConnectionString.Password.Length - 2)     $  ConnectionString.Password = $  FistChar + $  Stars + $  LastChar      return $  ConnectionString.ConnectionString } 

What are arguments against the usage of a ticker / marquee on websites?

I was recently asked to add a ticker (with daily updates) to one of our HTML-based dashboards. (A ticker would be text scrolling through the screen. In the past you could achieve something like that with the marquee tag in HTML.)

an example of a scrolling marquee/ticker

I personally don’t like tickers and think they are a thing of the last century, but that’s not really a good argument. There have to be better arguments though, because none of the websites I frequently visit use tickers anymore.

Do you now better arguments against the usage of tickers?

Accept variable number of arguments and execute them

I need a bash function to accept variable number of arguments. These arguments are other commands like ls /root, echo HI, git clone http:// ...., rm etc. The function executes the commands sequentially

The function must accept the arguments as:

myfun <arbitrary set of commands> 

Note that each command may have an arbitrary set of parameters for itself.

myfun echo H ls /root git clone http://.... /home/myh/git/x1  

myfun should execute as follows

echo H ls /root git clone http://.... /home/myh/git/x1 

The way arguments are passed to myfun can be changed. Is there a way to achieve the desired behavior?

How to start a systemd service with complex arguments?

I want to stream video from a Raspberry Pi with a USB camera using mjpg-streamer. Here is the commandline to start it from a bash shell:

./mjpg_streamer  -i "./" -o "./ -w ./www -p 8000" 

This works fine.

I have created the service file /lib/systemd/system/mjpg-streamer.service:

[Unit] Description=USB camera streaming service  [Service] Environment=LD_LIBRARY_PATH=/home/pi/mjpg-streamer EnvironmentFile=./mjpg-streamer.conf ExecStart=/home/pi/mjpg-streamer/mjpg_streamer $  {ARG1} $  {ARG2} StandardOutput=null Restart=always RestartSec=10  [Install] 

Here is my environment file /lib/systemd/system/mjpg-streamer.conf:

ARG1=-i "./"  ARG2=-o "./ -w ./www -p 8000" 

The service starts, but the arguments are not being passed in correctly.

Add arguments in CMS Block

The project is using the Bluefoot plugin to add the block in cms_index_home. I created a static block in Magento Admin with the follow content:

{{block class="Webjump\ProductsRegulars\Block\Recommendation\Lists" name="product-recommendation" template="recommendation/list.phtml}} 

But in my cms_index_home.xml I have some arguments essentials to block.

<arguments>     <argument name="jsLayout" xsi:type="array">         <item name="components" xsi:type="array">             <item name="recommendation-list" xsi:type="array">                 <item name="component" xsi:type="string">ProductsRegulars/js/view/recommendation/list</item>                 <item name="config" xsi:type="array">                     <item name="template" xsi:type="string">ProductsRegulars/recommendation/list</item>                 </item>                  <item name="children" xsi:type="array">                     <item name="messages" xsi:type="array">                         <item name="sortOrder" xsi:type="string">0</item>                         <item name="component" xsi:type="string">Magento_Ui/js/view/messages</item>                         <item name="displayArea" xsi:type="string">messages</item>                     </item>                 </item>             </item>         </item>     </argument> </arguments> 

When I run the page, occur the following error:

Uncaught SyntaxError: Unexpected token u in JSON at position 0 

I believe that this error occurs because of the Magento not found the arguments. Can anyone help me?